A MVC web application for managing a collection of watches. Built with ASP.NET Core (.NET 9), this project demonstrates CRUD operations, form validation, and dynamic UI rendering using Razor Pages.
##Note: This project is a simplified version of a watch management application and does not include a database. Instead, it uses in-memory data storage for demonstration purposes. It is designed to showcase the use of Razor Pages, form validation, and responsive design with Bootstrap. It is not intended for production use or real-world applications. only the CR (Create and Read) operations are implemented, with a focus on adding watches and displaying them in a list. This application is in production-ready state for https launch settings and can be used as a starting point for further development.
- List all watches with details
- Add new watches with brand, model, price, category, release year, image, and description
- Category and year selection with drop-downs
- Server-side and client-side validation
- Responsive design with Bootstrap
- Image URL validation with fall-back to a default image
- Clean separation of concerns using repositories and view models
- .NET 9
- ASP.NET Core Razor Pages
- Entity Framework Core (if used for data access)
- Bootstrap 5
- jQuery & jQuery Validation
WatchesApp.Web/
- Main Razor Pages web projectControllers/
- Handles HTTP requests and prepares view modelsModels/
- ViewModels and data models for watches and categoriesViews/
- Razor views for each pagewwwroot/
- Static files (CSS, JS, images)
- .NET 9 SDK
- Visual Studio 2022 or later
-
Clone the repository:
-
Restore dependencies:
-
Build and run the project:
-
Open your browser and navigate to
https://localhost:5001
(or the URL shown in the console).
Contributions are welcome! Please open issues or submit pull requests for improvements and bug fixes.
This project is licensed under the MIT License.
The solution has been refactored to follow a clearer separation of concerns between service and repository layers. The following changes have been made:
- Entities (previously called Models)
- Represents data
- No dependencies
- Services (business workflows and business logic)
- Interfaces for services and repositories
- Manages data
- Depends on the Domain project
### Folder Structure Example
Customer/
├── Services/
└── CustomerService.cs
├── Interfaces/
└── ICustomerService.cs
Product/
├── Services/
└── ProductService.cs
├── Interfaces/
└── IProductService.cs
- Repositories (e.g., Entity Framework implementations — not yet implemented)
- Unit of Work classes (not yet implemented)
- Coordinates write operations from multiple repositories into a single transaction
- May contain services (technical dependencies only – no business logic)
- Handles data persistence
- Depends on the Application project (and indirectly on Domain)
### Folder Structure Example
Persistence/
└── Repositories
Services/ (optional)
DependencyInjection/ (optional)
- Presentation layer, e.g., an MVC application
- Displays data to the user
- Depends on Infrastructure (and indirectly on Application and Domain projects)
-
Application
Services/WatchService.cs
Provides business logic and acts as a wrapper around the repository for watch management.Services/CategoryService.cs
Manages watch categories.
-
Infrastructure
Repositories/WatchRepository.cs
Handles in-memory storage and retrieval of watch entities. ImplementsIWatchRepository
.
-
Domain
Entities/Watch.cs
Represents the watch entity.Entities/Category.cs
Represents the category entity.
-
WatchesApp.Web
- (Razor Pages, UI, and web entry point)
- The
WatchService
class now delegates data access toIWatchRepository
and focuses on business logic. - The
WatchRepository
class is responsible for data persistence and retrieval, and is registered for dependency injection. - The solution structure now clearly separates application logic (services) from infrastructure concerns (repositories).
The solution now includes a console application project for interacting with the watch collection via the terminal.
-
Purpose:
Provides a simple command-line interface for listing all watches and retrieving details of a specific watch by ID. This project demonstrates the use of the service and repository layers outside of the web context. -
Key File:
Program.cs
- Entry point for the console application.
- Lists all watches (sorted by ID, brand, and model).
- Prompts the user to enter a watch ID and displays detailed information for the selected watch.
- Demonstrates usage of
WatchService
andWatchRepository
.
-
How it works:
- On launch, the application displays all available watches.
- The user is prompted to enter a watch ID to view its details.
- The application outputs the selected watch’s brand, model, price, release year, and availability.
-
Dependencies:
- Uses the same
Application
andInfrastructure
layers as the Razor Pages project, ensuring consistent business logic and data access.
- Uses the same
Note:
This console project is useful for testing and demonstration purposes, and can be extended for additional command-line operations as needed.