* 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
27 lines
826 B
C#
27 lines
826 B
C#
using Microsoft.eShopWeb.Services;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Microsoft.eShopWeb.Controllers
|
|
{
|
|
public class CatalogController : Controller
|
|
{
|
|
private readonly ICatalogService _catalogService;
|
|
|
|
public CatalogController(ICatalogService catalogService) => _catalogService = catalogService;
|
|
|
|
// GET: /<controller>/
|
|
public async Task<IActionResult> Index(int? brandFilterApplied, int? typesFilterApplied, int? page)
|
|
{
|
|
var itemsPage = 10;
|
|
var catalogModel = await _catalogService.GetCatalogItems(page ?? 0, itemsPage, brandFilterApplied, typesFilterApplied);
|
|
return View(catalogModel);
|
|
}
|
|
|
|
public IActionResult Error()
|
|
{
|
|
return View();
|
|
}
|
|
}
|
|
}
|