public ActionResult Create() { var appointment = new Appointment(); appointment.TimeRange = new TimeRange(); var model = new ViewModel_CreateAppointment(); model.Appointment = appointment; model.Hairdressers = _hg.GetAll(); model.Customers = _cg.GetAll(); return(View(model)); }
public ActionResult Edit(ViewModel_CreateAppointment model) { Appointment appointment = model.Appointment; appointment.Hairdresser = new Hairdresser(); appointment.Hairdresser.ID = model.selectedHairdresserID[0]; appointment.Customer = new Customer(); appointment.Customer.ID = model.selectedCustomerID[0]; if (ModelState.IsValid) { _ag.Update(appointment); } return(RedirectToAction("Index")); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Appointment appointment = _ag.Get(id.Value); var model = new ViewModel_CreateAppointment(); model.Appointment = appointment; model.Hairdressers = _hg.GetAll(); model.Customers = _cg.GetAll(); if (appointment == null) { return(HttpNotFound()); } return(View(model)); }