From fb2da83805b3bee4802ad34ca79bac4f36bdbf01 Mon Sep 17 00:00:00 2001 From: dsanz Date: Thu, 2 Mar 2017 16:59:03 +0100 Subject: [PATCH] Fix in monolithic part for issue #67 https://github.com/dotnet/eShopOnContainers/issues/67 ViewModels folder --- .../eShopWeb/Controllers/CatalogController.cs | 17 ++++++----------- .../eShopWeb/Services/CatalogService.cs | 5 ++--- .../eShopWeb/Services/ICatalogService.cs | 4 +--- .../eShopWeb/{Models => ViewModels}/Catalog.cs | 6 ++---- .../CatalogIndex.cs} | 11 ++++------- .../Pagination => ViewModels}/PaginationInfo.cs | 2 +- .../eShopWeb/Views/Catalog/Index.cshtml | 2 +- .../eShopWeb/Views/Catalog/_pagination.cshtml | 2 +- 8 files changed, 18 insertions(+), 31 deletions(-) rename src/Web/WebMonolithic/eShopWeb/{Models => ViewModels}/Catalog.cs (73%) rename src/Web/WebMonolithic/eShopWeb/{Models/CatalogViewModels/IndexViewModel.cs => ViewModels/CatalogIndex.cs} (65%) rename src/Web/WebMonolithic/eShopWeb/{Models/Pagination => ViewModels}/PaginationInfo.cs (91%) diff --git a/src/Web/WebMonolithic/eShopWeb/Controllers/CatalogController.cs b/src/Web/WebMonolithic/eShopWeb/Controllers/CatalogController.cs index 79b270314..33e62526c 100644 --- a/src/Web/WebMonolithic/eShopWeb/Controllers/CatalogController.cs +++ b/src/Web/WebMonolithic/eShopWeb/Controllers/CatalogController.cs @@ -1,15 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using eShopWeb.Models.CatalogViewModels; -using eShopWeb.Models; -using eShopWeb.Models.Pagination; -using Microsoft.AspNetCore.Mvc.Rendering; +using eShopWeb.Services; +using eShopWeb.ViewModels; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using System; using System.IO; -using eShopWeb.Services; +using System.Threading.Tasks; // For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 @@ -33,7 +28,7 @@ namespace eShopWeb.Controllers var itemsPage = 10; var catalog = await _catalogSvc.GetCatalogItems(page ?? 0, itemsPage, BrandFilterApplied, TypesFilterApplied); - var vm = new IndexViewModel() + var vm = new CatalogIndex() { CatalogItems = catalog.Data, Brands = await _catalogSvc.GetBrands(), diff --git a/src/Web/WebMonolithic/eShopWeb/Services/CatalogService.cs b/src/Web/WebMonolithic/eShopWeb/Services/CatalogService.cs index 5d930b116..26142e823 100644 --- a/src/Web/WebMonolithic/eShopWeb/Services/CatalogService.cs +++ b/src/Web/WebMonolithic/eShopWeb/Services/CatalogService.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using eShopWeb.Models; @@ -7,7 +6,7 @@ using Microsoft.AspNetCore.Mvc.Rendering; using eShopWeb.Infrastructure; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; -using Microsoft.Extensions.Configuration; +using eShopWeb.ViewModels; namespace eShopWeb.Services { diff --git a/src/Web/WebMonolithic/eShopWeb/Services/ICatalogService.cs b/src/Web/WebMonolithic/eShopWeb/Services/ICatalogService.cs index e642b2e78..7d8c8619b 100644 --- a/src/Web/WebMonolithic/eShopWeb/Services/ICatalogService.cs +++ b/src/Web/WebMonolithic/eShopWeb/Services/ICatalogService.cs @@ -1,8 +1,6 @@ -using eShopWeb.Models; +using eShopWeb.ViewModels; using Microsoft.AspNetCore.Mvc.Rendering; -using System; using System.Collections.Generic; -using System.Linq; using System.Threading.Tasks; namespace eShopWeb.Services diff --git a/src/Web/WebMonolithic/eShopWeb/Models/Catalog.cs b/src/Web/WebMonolithic/eShopWeb/ViewModels/Catalog.cs similarity index 73% rename from src/Web/WebMonolithic/eShopWeb/Models/Catalog.cs rename to src/Web/WebMonolithic/eShopWeb/ViewModels/Catalog.cs index 2c61b2520..2031f25ce 100644 --- a/src/Web/WebMonolithic/eShopWeb/Models/Catalog.cs +++ b/src/Web/WebMonolithic/eShopWeb/ViewModels/Catalog.cs @@ -1,9 +1,7 @@ -using System; +using eShopWeb.Models; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -namespace eShopWeb.Models +namespace eShopWeb.ViewModels { public class Catalog { diff --git a/src/Web/WebMonolithic/eShopWeb/Models/CatalogViewModels/IndexViewModel.cs b/src/Web/WebMonolithic/eShopWeb/ViewModels/CatalogIndex.cs similarity index 65% rename from src/Web/WebMonolithic/eShopWeb/Models/CatalogViewModels/IndexViewModel.cs rename to src/Web/WebMonolithic/eShopWeb/ViewModels/CatalogIndex.cs index 95744b2f1..75aec23f6 100644 --- a/src/Web/WebMonolithic/eShopWeb/Models/CatalogViewModels/IndexViewModel.cs +++ b/src/Web/WebMonolithic/eShopWeb/ViewModels/CatalogIndex.cs @@ -1,13 +1,10 @@ -using Microsoft.AspNetCore.Mvc.Rendering; -using eShopWeb.Models.Pagination; -using System; +using eShopWeb.Models; +using Microsoft.AspNetCore.Mvc.Rendering; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -namespace eShopWeb.Models.CatalogViewModels +namespace eShopWeb.ViewModels { - public class IndexViewModel + public class CatalogIndex { public IEnumerable CatalogItems { get; set; } public IEnumerable Brands { get; set; } diff --git a/src/Web/WebMonolithic/eShopWeb/Models/Pagination/PaginationInfo.cs b/src/Web/WebMonolithic/eShopWeb/ViewModels/PaginationInfo.cs similarity index 91% rename from src/Web/WebMonolithic/eShopWeb/Models/Pagination/PaginationInfo.cs rename to src/Web/WebMonolithic/eShopWeb/ViewModels/PaginationInfo.cs index 4ffd4035b..2eea3f602 100644 --- a/src/Web/WebMonolithic/eShopWeb/Models/Pagination/PaginationInfo.cs +++ b/src/Web/WebMonolithic/eShopWeb/ViewModels/PaginationInfo.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace eShopWeb.Models.Pagination +namespace eShopWeb.ViewModels { public class PaginationInfo { diff --git a/src/Web/WebMonolithic/eShopWeb/Views/Catalog/Index.cshtml b/src/Web/WebMonolithic/eShopWeb/Views/Catalog/Index.cshtml index 2b529ca7b..5866261f6 100644 --- a/src/Web/WebMonolithic/eShopWeb/Views/Catalog/Index.cshtml +++ b/src/Web/WebMonolithic/eShopWeb/Views/Catalog/Index.cshtml @@ -1,6 +1,6 @@ @{ ViewData["Title"] = "Catalog"; - @model eShopWeb.Models.CatalogViewModels.IndexViewModel + @model eShopWeb.ViewModels.CatalogIndex }
diff --git a/src/Web/WebMonolithic/eShopWeb/Views/Catalog/_pagination.cshtml b/src/Web/WebMonolithic/eShopWeb/Views/Catalog/_pagination.cshtml index 8bd5b2641..1c67eaa58 100644 --- a/src/Web/WebMonolithic/eShopWeb/Views/Catalog/_pagination.cshtml +++ b/src/Web/WebMonolithic/eShopWeb/Views/Catalog/_pagination.cshtml @@ -1,4 +1,4 @@ -@model eShopWeb.Models.Pagination.PaginationInfo +@model eShopWeb.ViewModels.PaginationInfo