Category Archives: Learn by doing – ASP.Net MVC

Shoppingcart Application Part-16 (Product Catalog Controllers)

View Models: We’ll use view models to create strongly typed .cshtml view. Following view models will strongly typed with corresponding cshtml views a. BaseProductCatalogView b. HomePageView c. ProductDetailView d. ProductSearchResultView Add a new folder inside Shoppingcart.Controllers project and named it to ViewModels. Add another folder within ViewModels and named it to ProductCatalog. Inside ProductCatalog folder… Read More »

Shoppingcart Application Part-15 (ProductCatalogService – Implementation)

Now we’ll implementation of the IProductCatalogService is named ProductCatalogService and can be seen in the following code listing. A description of the code follows the listing: public class ProductCatalogService : IProductCatalogService { private readonly IProductTitleRepository _productTitleRepository; private readonly IProductRepository _productRepository; private readonly ICategoryRepository _categoryRepository; public ProductCatalogService(IProductTitleRepository productTitleRepository, IProductRepository productRepository, ICategoryRepository categoryRepository) { _productTitleRepository = productTitleRepository;… Read More »

Shopping Cart Application Part-11 (ViewModels)

Before we ditails discuss about ViewModels we’ll discuss about the role of Service layer in our application. @. In our project the service layer will coordinate the retrieval and persistence of business entities. @. A service receives requests from the controllers for updates to the domain model as well as a specific view of the… Read More »

Shopping Cart Application Part-09 (Repository classes)

@. Now we’ll create base repository class that will implement IRepository interface (that we defined inside Shoppingcart.Infrastructure layer). @. Let’s add a class and named it Repository with following definition: public abstract class Repository : IRepository where T : BaseEntity, IAggregateRoot { private ShoppingcartContext dataContext; private readonly DbSet dbset; protected Repository(IDataContextFactory dataContextFactory) { DataContextFactory =… Read More »

Shopping Cart Application Part-07 (Repository contracts)

@In my previous post I discussed about Product Catalog. @. Now I will create Repository interfaces. @. These interfaces actually act like contracts with their implementations. @. They will also specify what will must implement by a concrete class (that implements the interface) @. In our Product catalog we defined three entities as Aggregate Root… Read More »