public ViewResult MakeBooking(Appointment appt)
        {
            //if (string.IsNullOrEmpty(appt.ClientName)) {
            //    ModelState.AddModelError("ClientName", "Please enter your name");
            //}

            //if (ModelState.IsValidField("Date") && DateTime.Now > appt.Date) {
            //    ModelState.AddModelError("Date", "Please enter a date in the future");
            //}

            //if (!appt.TermsAccepted) {
            //    ModelState.AddModelError("TermsAccepted", "You must accept the terms");
            //}

            //if (ModelState.IsValidField("ClientName") && ModelState.IsValidField("Date")
            //    && appt.ClientName == "Joe" && appt.Date.DayOfWeek == DayOfWeek.Monday) {
            //    ModelState.AddModelError("", "Joe cannot book appointments on Mondays");
            //}

            if (ModelState.IsValid) {
            repository.SaveAppointment(appt);
            return View("Completed", appt);
            } else {
            return View();
            }
        }
예제 #2
0
 public ActionResult Index(Appointment app)
 {
     if (Request.IsAjaxRequest()) {
     return Json(new {
         ClientName = app.ClientName,
         Date = app.Date.ToShortDateString(),
         TermsAccepted = app.TermsAccepted
     });
     } else {
     return View();
     }
 }