public ActionResult CreateNewBook(BookingMV newbooking) { if (check == false) { TempData["checkbooking"] = "please check your date"; newbooking = booking.openbookingCreate(newbooking); return(View("Create", newbooking)); } DateTime timebb = (DateTime)newbooking.BookingPagedata; newbooking.FinishTime = timebb.AddMinutes(30); newbooking.type = "Pending"; ResponseMV result = booking.createnewbooking(newbooking); if (result.IsValid == true && check == true) { TempData["SaveBooking"] = "Booking save success"; return(RedirectToAction("Index")); } else { foreach (var item in result.ErrorMessages) { ModelState.AddModelError(item.Key, item.Value); } if (check == false) { TempData["checkbooking"] = "please check your date"; } newbooking = booking.openbookingCreate(newbooking); return(View("Create", newbooking)); } }
public BookingMV openbookingCreate(BookingMV model = null) { LookupBussiness look = new LookupBussiness(); if (model == null) { model = new BookingMV(); } model.PatientList = look.fillpatient(); model.SpecList = look.fillspec(); return(model); }
public ResponseMV Validatebooking(BookingMV viewmodel) { DateTime timebook = new DateTime(); timebook = (DateTime)viewmodel.BookingPagedata; BookingMV resulttime = Bookssearch(viewmodel); ResponseMV result = new ResponseMV(); if (viewmodel.Doctorid == null) { result.ErrorMessages.Add("Doctorid", "not found name"); } if (viewmodel.patientid == null) { result.ErrorMessages.Add("patientid", "not found name"); } if (viewmodel.Specialtyid == null) { result.ErrorMessages.Add("Specialtyid", "not found name"); } if (resulttime != null) { result.ErrorMessages.Add("BookingPagedata", "not correct time you must choose after " + resulttime.FinishTime); } if (viewmodel.DateBooking == null) { result.ErrorMessages.Add("DateBooking", "can not save empty date"); } if (viewmodel.DateBooking < DateTime.Now) { result.ErrorMessages.Add("DateBooking1", "this date not coorect choose day after this date" + viewmodel.DateBooking); } if (viewmodel.BookingPagedata == null) { result.ErrorMessages.Add("BookingPagedata1", "can not save empty time"); } if (timebook.Minute > 0 && timebook.Minute != 30) { result.ErrorMessages.Add("BookingPagedata2", "can not save this time you must choose time without minute"); } result.IsValid = result.ErrorMessages.Count == 0 ? true : false; return(result); }
public BookingMV Bookssearch(BookingMV timebooking) { var books = clinic.BookingTBLs.Where(b => b.BookingPagedata == timebooking.BookingPagedata && b.Doctorid == timebooking.Doctorid && b.DateBooking == timebooking.DateBooking && b.type == "Pending"); return(books.Select(c => new BookingMV { id = c.id, DoctorNmae = c.DoctorTBL.DoctorName, PatientName = c.PatientTBL.PatientName, SpecNmae = c.SpecialtyTBL.SpecialtyName, BookingPagedata = c.BookingPagedata, DateBooking = c.DateBooking, FinishTime = c.FinishTime, }).SingleOrDefault()); }
public ResponseMV createnewbooking(BookingMV Booking) { ResponseMV result = Validatebooking(Booking); if (result.IsValid == true) { BookingTBL doctortemp = new BookingTBL(); doctortemp.Doctorid = Booking.Doctorid; doctortemp.patientid = Booking.patientid; doctortemp.Specialtyid = Booking.Specialtyid; doctortemp.BookingPagedata = Booking.BookingPagedata; doctortemp.DateBooking = Booking.DateBooking; doctortemp.FinishTime = Booking.FinishTime; doctortemp.type = Booking.type; clinic.BookingTBLs.Add(doctortemp); clinic.SaveChanges(); } return(result); }
// GET: Booking/Create public ActionResult Create() { BookingMV bookingopen = booking.openbookingCreate(); return(View(bookingopen)); }