public ActionResult Book(string DateOfBirth, string PreferredDate, string PreferredTime, string PreferredDoctor) { //Set the appointment object to add in database OnlineAppointmentBooking booking = new OnlineAppointmentBooking(); //Assign value to booking.PatientDateOfBirth = DateTime.ParseExact(DateOfBirth, "MM/dd/yyyy", CultureInfo.InvariantCulture); booking.PreferredDate = DateTime.ParseExact(PreferredDate, "MM/dd/yyyy", CultureInfo.InvariantCulture); booking.PreferredTime = PreferredTime; booking.PreferredDoctor = PreferredDoctor; booking.UserId = User.Identity.GetUserId(); Debug.WriteLine("User id who is booking an appointment : " + User.Identity.GetUserId()); booking.OnlineAppointmentBookingBookedOn = DateTime.Now; booking.OnlineAppointmentBookingStatus = (int)OnlineAppointmentBookingStatus.InProcess; string currentUserId = User.Identity.GetUserId(); //Get current user to set the FK data for an appointment. booking.User = db.Users.FirstOrDefault(x => x.Id == currentUserId); //Add appointment record in to the databse db.OnlineAppointmentBookings.Add(booking); //Save data into database db.SaveChanges(); //Redirect to List Page return(RedirectToAction("List")); }
public ActionResult View(int id) { Debug.WriteLine("viwe a booking appointment id : " + id); //Get the booked appoitment booking details according to Id OnlineAppointmentBooking onlineAppointmentBooking = db.OnlineAppointmentBookings.Include("User").Where(x => x.OnlineAppointmentBookingId == id).FirstOrDefault(); //Return booking detail return(View(onlineAppointmentBooking)); }
public ActionResult UpdateStatus(int id) { //Update the status of the booking - logged in user can cancel the past booked appointment if the status is booked or cancelled. OnlineAppointmentBooking onlineAppointmentBooking = db.OnlineAppointmentBookings.Include("User").Where(x => x.OnlineAppointmentBookingId == id).FirstOrDefault(); onlineAppointmentBooking.OnlineAppointmentBookingStatus = (int)OnlineAppointmentBookingStatus.Cancelled; Debug.WriteLine("update booking status appointment id : " + id); //save into database db.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Update(int id) { //ViewModel UpdateOnlineAppointmentBookingViewModel UpdateOnlineAppointmentBookingViewModel = new UpdateOnlineAppointmentBookingViewModel(); Debug.WriteLine("Updating a booking appointment id : " + id); //Get the appointment detail OnlineAppointmentBooking OnlineAppointmentBooking = db.OnlineAppointmentBookings.Include("User").Where(x => x.OnlineAppointmentBookingId == id).FirstOrDefault(); //Assign value to viewmodel UpdateOnlineAppointmentBookingViewModel.OnlineAppointmentBooking = OnlineAppointmentBooking; UpdateOnlineAppointmentBookingViewModel.OnlineAppointmentBookingStatus = (OnlineAppointmentBookingStatus)Enum.ToObject(typeof(OnlineAppointmentBookingStatus), Convert.ToInt32(OnlineAppointmentBooking.OnlineAppointmentBookingStatus)); //Return all bookings to the listing page return(View(UpdateOnlineAppointmentBookingViewModel)); }
public ActionResult Update(int id, string DateOfBirth, string PreferredDate, string PreferredTime, string PreferredDoctor, int OnlineAppointmentBookingStatus) { Debug.WriteLine("Updating a booking appointment id : " + id); //Get the booked appoitment booking details OnlineAppointmentBooking onlineAppointmentBooking = db.OnlineAppointmentBookings.Include("User").Where(x => x.OnlineAppointmentBookingId == id).FirstOrDefault(); //Assign the updated details onlineAppointmentBooking.PatientDateOfBirth = Convert.ToDateTime(DateOfBirth); onlineAppointmentBooking.PreferredDate = Convert.ToDateTime(PreferredDate); onlineAppointmentBooking.PreferredTime = PreferredTime; onlineAppointmentBooking.PreferredDoctor = PreferredDoctor; onlineAppointmentBooking.OnlineAppointmentBookingStatus = OnlineAppointmentBookingStatus; //Update the booking details online db.SaveChanges(); //Return all bookings to the listing page return(RedirectToAction("List")); }