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<T, TId> : IRepository<T, TId> where T : BaseEntity<TId>, IAggregateRoot { private ShoppingcartContext dataContext; private readonly DbSet<T> dbset; protected Repository(IDataContextFactory dataContextFactory) {… Read More »

Constructor in C#

Constructor: A special method of the class that will be automatically invoked when an instance of the class is created is called as constructor. A constructor doesn’t have any return type, not even void. A constructor can be called another constructor by using “this” keyword. “this” keyword is the current instance of a class. A class… Read More »

Shopping Cart Application Part-08 (Data access)

@. We have created our domain model. @. Now we’ll create a class in order to working with Entity Framework Code First. @. So inside Shoppingcart.Repositories project we’ll download Entity Framework from NuGet as follows: Install-Package EntityFramework Now we’ll add a database context class. This class will coordinate Entity Framework functionality for a given data… 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 »