Refactoring and Adding Tests (#28)
* Introducing repository and refactoring services. Changing entities to use int keys everywhere. * Refactoring application services to live in web project and only reference repositories, not EF contexts. * Cleaning up implementations * Moving logic out of CatalogController Moving entity knowledge out of viewmodels. * Implementing specification includes better for catalogservice * Cleaning up and adding specification unit tests
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
|
||||
public class BasketItemViewModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string ProductId { get; set; }
|
||||
public int Id { get; set; }
|
||||
public int CatalogItemId { get; set; }
|
||||
public string ProductName { get; set; }
|
||||
public decimal UnitPrice { get; set; }
|
||||
public decimal OldUnitPrice { get; set; }
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Microsoft.eShopWeb.ViewModels
|
||||
|
||||
public class BasketViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public List<BasketItemViewModel> Items { get; set; } = new List<BasketItemViewModel>();
|
||||
public string BuyerId { get; set; }
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
public class Catalog
|
||||
{
|
||||
public int PageIndex { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
public int Count { get; set; }
|
||||
public List<CatalogItem> Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,13 @@ using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
public class CatalogIndex
|
||||
public class CatalogIndexViewModel
|
||||
{
|
||||
public IEnumerable<CatalogItem> CatalogItems { get; set; }
|
||||
public IEnumerable<CatalogItemViewModel> CatalogItems { get; set; }
|
||||
public IEnumerable<SelectListItem> Brands { get; set; }
|
||||
public IEnumerable<SelectListItem> Types { get; set; }
|
||||
public int? BrandFilterApplied { get; set; }
|
||||
public int? TypesFilterApplied { get; set; }
|
||||
public PaginationInfo PaginationInfo { get; set; }
|
||||
public PaginationInfoViewModel PaginationInfo { get; set; }
|
||||
}
|
||||
}
|
||||
14
src/Web/ViewModels/CatalogItemViewModel.cs
Normal file
14
src/Web/ViewModels/CatalogItemViewModel.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
|
||||
public class CatalogItemViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string PictureUri { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using Microsoft.eShopWeb.ApplicationCore.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
namespace Microsoft.eShopWeb.ViewModels
|
||||
{
|
||||
public class PaginationInfo
|
||||
public class PaginationInfoViewModel
|
||||
{
|
||||
public int TotalItems { get; set; }
|
||||
public int ItemsPerPage { get; set; }
|
||||
Reference in New Issue
Block a user