Error action extracted from CatalogController, because otherwise was violated Single Responsibility Principal, when even to generate an Error we will create Transient ICatalogService for each error.

This commit is contained in:
IgorSychev 2017-06-22 14:58:56 +03:00 committed by Igor Sychev
parent 09dfd9a246
commit c43d1922a1
3 changed files with 15 additions and 8 deletions

View File

@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
using Microsoft.eShopOnContainers.WebMVC.Services;
using Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels;
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
{
public class CatalogController : Controller
@ -42,8 +39,5 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
return View(vm);
}
public IActionResult Error() => View();
}
}
}

View File

@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Mvc;
namespace WebMVC.Controllers
{
public class ErrorController : Controller
{
public IActionResult Error() => View();
}
}

View File

@ -102,7 +102,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
}
else
{
app.UseExceptionHandler("/Catalog/Error");
app.UseExceptionHandler("/Error");
}
app.UseSession();
@ -145,6 +145,10 @@ namespace Microsoft.eShopOnContainers.WebMVC
routes.MapRoute(
name: "default",
template: "{controller=Catalog}/{action=Index}/{id?}");
routes.MapRoute(
name: "defaultError",
template: "{controller=Error}/{action=Error}");
});
}
}