Category Archives: Asp.net MVC

MVC Routing

What is Routing? Routing simplifies MVC url. Routing helps us to create user friendly url and those urls can easily maps with technical controller names and action names. How to simplify the url? Some developers maintains some coding standard i.e. naming standard like using prefix word Cls before class name e.g. ClsHomeController. Also some developers… Read More »

First Application in ASP.NET MVC

Open visual studio so following like window will open: From above window click on File Menu -> New -> Project as follows: So a dialog box will appear to us. From this dialog click “Web” menu so it will show “ASP.NET Web Application” template as follows: Inside above “Web” menu there is also a submenu… Read More »

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