public CreateMaintenanceBookingViewModel Create() { var brands = _brandQuery.Execute(); var maintenanceOptions = _maintenanceOptionsQuery.Execute(); var createMaintenanceBookingViewModel = new CreateMaintenanceBookingViewModel(); createMaintenanceBookingViewModel.Brands = brands.Result.Select( b => new SelectListItem { Value = b.Id.ToString(), Text = b.Name }).ToList(); createMaintenanceBookingViewModel.MaintenanceOptions = maintenanceOptions.Result.Select( m => new SelectListItem { Value = m.Id.ToString(), Text = m.Description }).ToList(); createMaintenanceBookingViewModel.CreateMaintenanceBookingModel = new CreateMaintenanceBookingModel { VehicleRegistrationDate = DateTime.Now }; return(createMaintenanceBookingViewModel); }
public IActionResult Create(CreateMaintenanceBookingViewModel viewModel) { var createMaintenanceBookingModel = new CreateMaintenanceBookingModel() { BrandId = viewModel.CreateMaintenanceBookingModel.BrandId, CustomerFirstName = viewModel.CreateMaintenanceBookingModel.CustomerFirstName, CustomerLastName = viewModel.CreateMaintenanceBookingModel.CustomerLastName, MaintenanceBookingDateTime = viewModel.CreateMaintenanceBookingModel.MaintenanceBookingDateTime, VehicleRegistrationDate = viewModel.CreateMaintenanceBookingModel.VehicleRegistrationDate, VehicleRegistrationNumber = viewModel.CreateMaintenanceBookingModel.VehicleRegistrationNumber, MaintenanceServicesIds = viewModel.MaintenanceOptions.FindAll(x => x.Selected = true).Select(item => int.Parse(item.Value)).ToList() }; _createCommand.Execute(createMaintenanceBookingModel); return(View("BookingConfirmation")); }