public ActionResult CreateAppointment(int vehicleId) { var vehicle = _vehicleService.GetById(vehicleId); if (vehicle == null) { return(RedirectToAction("Index", "Home")); } var model = new AppointmentVehicleViewModel(); //model.Vehicle.Brand = vehicle.Brand; model.Vehicle = new VehicleViewModel { id = vehicle.id, licensePlate = vehicle.licensePlate, brand = vehicle.brand, model = vehicle.model, modelYear = vehicle.modelYear }; model.Date = DateTime.Now.AddDays(1); return(View(model)); }
public ActionResult CreateAppointment(AppointmentVehicleViewModel model) { var appointment = new Appointment(); appointment.date = model.Date; appointment.vehicleId = model.Vehicle.id; _appointmentService.InsertAppointment(appointment); return(RedirectToAction("Appointments", "Appointment")); }