From de34e79755be6511cbf8107e7356a8d22b5170fd Mon Sep 17 00:00:00 2001 From: AlexFromKiyv <81460397+AlexFromKiyv@users.noreply.github.com> Date: Tue, 2 Dec 2025 12:45:02 +0200 Subject: [PATCH] Update Index.cshtml.cs. Here you can take advantage of the BasePageModel class. Here you can take advantage of the BasePageModel class. What has already been done there is repeated. --- .../AutoLot.Web/Pages/Cars/Index.cshtml.cs | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/Chapter_34/AutoLot.Web/Pages/Cars/Index.cshtml.cs b/Chapter_34/AutoLot.Web/Pages/Cars/Index.cshtml.cs index d005f5e..2aa03b0 100644 --- a/Chapter_34/AutoLot.Web/Pages/Cars/Index.cshtml.cs +++ b/Chapter_34/AutoLot.Web/Pages/Cars/Index.cshtml.cs @@ -1,19 +1,12 @@ namespace AutoLot.Web.Pages.Cars; -public class IndexModel : PageModel +public class IndexModel : BasePageModel { - private readonly IAppLogging _appLogging; - private readonly ICarDataService _carService; - - [ViewData] - public string Title => "Inventory"; - - public IndexModel(IAppLogging appLogging, ICarDataService carService) - { - _appLogging = appLogging; - _carService = carService; - } - + public IndexModel( + IAppLogging appLogging, + ICarDataService dataService) : base(appLogging, dataService, "Inventory") + {} + public string MakeName { get; set; } public int? MakeId { get; set; } public IEnumerable CarRecords { get; set; } @@ -21,6 +14,6 @@ public async Task OnGetAsync(int? makeId, string makeName) { MakeId = makeId; MakeName = makeName; - CarRecords = await _carService.GetAllByMakeIdAsync(makeId); + CarRecords = await ((ICarDataService)DataService).GetAllByMakeIdAsync(makeId); } -} \ No newline at end of file +}