public async Task <ActionResult> Create(Models.Booking booking) { if (ModelState.IsValid) { //Sms sms = new Sms(); //HttpCookie myCookie = new HttpCookie("MyCookie"); //myCookie = Request.Cookies["MyCookie"]; //int Id = Convert.ToInt16(myCookie); //try //{ // sms.Send_SMS(booking.PhoneNumber, "Hi, your booking has been successfully captured. Please consistantly check your status"); //} //catch //{ // ViewBag.Error = "Invalid network"; //} booking.DateTimeStamp = DateTime.Now; booking.Id = Guid.NewGuid(); booking.CustomerId = User.Identity.GetUserId(); booking.Status = "Pending"; await _booking.CreateBooking(booking); return(RedirectToAction("Index")); } ViewBag.CarMakes = new SelectList(await _make.GetMakes(), "Name", "Name"); ViewBag.Services = new SelectList(await _booking.GetServiceTypes(), "Type", "Type"); return(View(booking)); }
public string Create([FromBody] APICustomerBooking data) { var booking = new Booking() { AccountId = data.AccountId, CustomerId = data.CustomerId, RoomId = data.RoomId, BedId = data.BedId, CheckinDate = Convert.ToDateTime(data.CheckinDate), CheckOutDate = Convert.ToDateTime(data.CheckoutDate), Totalprice = data.TotalPrice }; _ibooking.CreateBooking(booking); var bookingID = booking.BookingId; var bookedBeds = new BookedBeds() { BookingId = bookingID, BedId = data.BedId, Check_In = Convert.ToDateTime(data.CheckinDate), Check_Out = Convert.ToDateTime(data.CheckoutDate) }; _bookedBeds.InsertBookedBed(bookedBeds); return("false"); }
public void BookingUpdateTests_Succeed_When_Availability_Exist() { // mocking a new patient var patient = new Patient { FullName = "Brook Shield", Email = "*****@*****.**" }; var patientID = _patientRepository.AddPatient(patient); // mocking up a new booking for cancellation var booking = new Booking { PatientID = patientID, StartDate = DateTime.Parse("28 Dec 2020 10:15"), EquipmentID = 0, bookingStatus = BookingStatus.Live }; _bookingService = new BookingService(_bookingRepositoryService, _patientRepository, _equipmentApi, _emailSetting); var response = _bookingService.CreateBooking(booking.PatientID, booking.StartDate); // preparing updating // setting a new appt date request var newAppointmentDate = DateTime.Parse("29 Dec 2020 08:00"); response = _bookingService.UpdateBooking(patientID, booking.StartDate, newAppointmentDate); // displaying response message _output.WriteLine(response.Result.Message); // displaying errors if any if (response.Result.Errors != null) { foreach (var err in response.Result.Errors) { _output.WriteLine(err.Message); } } Assert.True(true); }
public void BookingCancellationTests_When_Booking_NotExist() { // mocking a new the patient var patient = new Patient { FullName = "Brook Shield", Email = "*****@*****.**" }; var patientID = _patientRepository.AddPatient(patient); // mocking up a new booking for cancellation var booking = new Booking { PatientID = patientID, StartDate = DateTime.Parse("28 Dec 2020 10:15"), EquipmentID = 1, bookingStatus = BookingStatus.Live }; _bookingService = new BookingService(_bookingRepositoryService, _patientRepository, _equipmentApi, _emailSetting); var response = _bookingService.CreateBooking(booking.PatientID, booking.StartDate); // preparing cancellation //invalidating existing booking by changing to different date booking.StartDate = DateTime.Parse("29 Dec 2020 10:15"); response = _bookingService.CancelBooking(patientID, booking.StartDate); // displaying response message _output.WriteLine(response.Result.Message); // displaying errors if any if (response.Result.Errors != null) { foreach (var err in response.Result.Errors) { _output.WriteLine(err.Message); } } Assert.True(true); }
public void BookingSelectTests_GetAll_Bookings_for_Today() { // mocking a new patient var patient = new Patient { FullName = "Brook Shield", Email = "*****@*****.**" }; var patientID = _patientRepository.AddPatient(patient); // mocking up a new booking var booking = new Booking { PatientID = patientID, StartDate = DateTime.Parse("28 Dec 2020 10:15"), EquipmentID = 0, bookingStatus = BookingStatus.Live }; _bookingService = new BookingService(_bookingRepositoryService, _patientRepository, _equipmentApi, _emailSetting); var response = _bookingService.CreateBooking(booking.PatientID, booking.StartDate); // tweaking appointment date to make a valid case for today selection var newAppointmentDate = DateTime.Now.Date; var bookings = _bookingService.GetTodayBooking(); // displaying booking if (bookings != null) { foreach (var bk in bookings.Result) { _output.WriteLine($"{bk.BookingID}: {bk.bookingStatus}:{bk.EquipmentID}: {bk.PatientID} {bk.StartDate}: {bk.EndDate} "); } } Assert.True(true); }
public void BookingCreateTest_WhenEquipment_NotAvailable() { var booking = new Booking { PatientID = 1, StartDate = DateTime.Parse("30 Dec 2020 11:15"), EquipmentID = 0, bookingStatus = BookingStatus.Request, }; // mocking a new patient for email address notification later var patient = new Patient { FullName = "Brook Shield", Email = "*****@*****.**" }; var patientID = _patientRepository.AddPatient(patient); _bookingService = new BookingService(_bookingRepositoryService, _patientRepository, _equipmentApi, _emailSetting); var response = _bookingService.CreateBooking(booking.PatientID, booking.StartDate); // displaying response message _output.WriteLine(response.Result.Message); // displaying errors if any if (response.Result.Errors != null) { foreach (var err in response.Result.Errors) { _output.WriteLine(err.Message); } } Assert.True(true); }
public Task <ClientResponse> CreateNewBooking([FromBody] int patientId, DateTime appointmentDate) { return(_booking.CreateBooking(patientId, appointmentDate)); }