public async Task <IActionResult> Packages(int id) { PackageServicesViewModel packageViewModel = new PackageServicesViewModel(); packageViewModel.Packages = await _context.GetPackagesWithServicesByVehicleAsync(id); packageViewModel.Services = await _context.GetVehicleServices(id); packageViewModel.Vehicle = await _context.GetVehicleById(id); packageViewModel.Categories = _dbContext.Categories.Include(a => a.ServiceCategory).ThenInclude(a => a.Service).Where(a => a.ServiceCategory.Any(a => a.Service.VehicleId == packageViewModel.Vehicle.Id)); packageViewModel.ServiceCategories = await _dbContext.ServiceCategories.OrderBy(a => a.Service.DisplayOrder).ToListAsync(); return(View(packageViewModel)); }
public async Task <IActionResult> EditServices(int id) { // Idea: // Just list the services, with an add button/remove button. // Loop through service list, if item is in the service package list, add del button // Otherwise add add button PackageServicesViewModel viewModel = new PackageServicesViewModel(); viewModel.Package = await _context.GetPackageByIdAsync(id); viewModel.ServicePackages = await _context.GetServicesByPackage(viewModel.Package.Id); viewModel.Services = await _context.GetVehicleServices(viewModel.Package.VehicleId); // Filter list of services, so ones already a part of the package aren't shown. viewModel.Services = viewModel.Services.Except(viewModel.ServicePackages); return(View(viewModel)); }