public ViewResult MakeBooking(Appointment app) { if (ModelState.IsValid) { repo.SaveApp(app); return View("Complete", repo.ApointmentRepository); } else { return View(); } }
public ViewResult MakeBooking(Appointment app) { ////if (string.IsNullOrEmpty(app.ClientName)) // Явная проверка достоверности модели ////{ //// ModelState.AddModelError("ClientName", "Please enter your name!"); ////} ////if (ModelState.IsValidField("Date") && DateTime.Now > app.Date) ////{ //// ModelState.AddModelError("Date","Please enrter data!"); ////} ////if(!app.TermsAccepted) ////{ //// ModelState.AddModelError("TermsAccepted", "Pleasere click by check"); ////} ////if(ModelState.IsValidField("ClientName")&& ModelState.IsValidField("Date")&& app.ClientName=="A"&&app.Date.DayOfWeek==DayOfWeek.Monday) ////{ //// ModelState.AddModelError("", "Error A"); ////} ////if (ModelState.IsValid) ////{ //// repo.SaveApp(app); //// return View("Complete", repo.ApointmentRepository); ////} ////else ////{ //// return View(); ////} if (ModelState.IsValid) { repo.SaveApp(app); return View("Complete", repo.ApointmentRepository); } else { return View(); } }
public void SaveApp(Appointment apps) { app.Add(apps); }