public ActionResult Create(AppointmentBindingModel model) { if (!ModelState.IsValid) { return(View()); } string userId = User.Identity.GetUserId(); var appointment = new Appointment() { StartDateTime = model.StartDateTime, EndDateTime = model.EndDateTime, UserId = userId }; if (service.Create(appointment, userId)) { return(RedirectToAction("Index")); } else { int allowedAppointments = int.Parse(System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/") + "applicationSettings.txt")); ModelState.AddModelError("", "There are already " + allowedAppointments + " parallel appointments"); return(View()); } }
public ActionResult Edit(AppointmentBindingModel model, int id) { if (!ModelState.IsValid) { ViewBag.Id = id; return(View()); } var appointment = service.Get(id); appointment.StartDateTime = model.StartDateTime; appointment.EndDateTime = model.EndDateTime; service.Update(appointment); return(RedirectToAction("Index")); }