Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions Chapter_34/AutoLot.Web/Pages/Cars/Index.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
namespace AutoLot.Web.Pages.Cars;

public class IndexModel : PageModel
public class IndexModel : BasePageModel<Car, IndexModel>
{
private readonly IAppLogging<IndexModel> _appLogging;
private readonly ICarDataService _carService;

[ViewData]
public string Title => "Inventory";

public IndexModel(IAppLogging<IndexModel> appLogging, ICarDataService carService)
{
_appLogging = appLogging;
_carService = carService;
}

public IndexModel(
IAppLogging<IndexModel> appLogging,
ICarDataService dataService) : base(appLogging, dataService, "Inventory")
{}

public string MakeName { get; set; }
public int? MakeId { get; set; }
public IEnumerable<Car> CarRecords { get; set; }
public async Task OnGetAsync(int? makeId, string makeName)
{
MakeId = makeId;
MakeName = makeName;
CarRecords = await _carService.GetAllByMakeIdAsync(makeId);
CarRecords = await ((ICarDataService)DataService).GetAllByMakeIdAsync(makeId);
}
}
}