/*------------------------------------------------END OF Getting List of Bookings------------------------------------------------*/ //Deleting the user from userDetails using the id public bool DeleteBooking(int id) { ConfirmBooking bookingDetails = dbContext.booking.Find(id); if (bookingDetails != null) { dbContext.booking.Remove(bookingDetails); dbContext.SaveChanges(); return(true); } else { return(false); } }
/// <summary> /// Booking details are added to Database /// </summary> /// <param name="confirmbooking"></param> /// <returns>int</returns> public bool Confirm_Booking(BookingTransfer confirmbooking) { //book is the object for Booking class //assigning the values of Booking Transfer to Confirmbooking ConfirmBooking book = new ConfirmBooking(); book.bookingAmount = confirmbooking.bookingAmount; book.checkInDate = confirmbooking.checkInDate; book.checkOutDate = confirmbooking.checkOutDate; book.discountAmount = confirmbooking.discountAmount; book.bookingDate = DateTime.Today; confirmbooking.bookingDate = book.bookingDate; List <int> findbooking = dbContext.roomBookingDetails.Where(x => x.roomId == confirmbooking.roomId).Select(y => y.bookingId).ToList(); foreach (var bookId in findbooking) { ConfirmBooking findbook = dbContext.booking.Find(bookId); if (!((findbook.checkInDate >= confirmbooking.checkInDate && findbook.checkInDate >= confirmbooking.checkOutDate) || (findbook.checkOutDate <= confirmbooking.checkInDate && findbook.checkOutDate <= confirmbooking.checkOutDate))) { return(false); } } //updating the database with object try { // Adding new row to Booking table with Add method dbContext.booking.Add(book); //After adding saving changes with SaveChanges method dbContext.SaveChanges(); } //catch block will be called when any error occurs while saving in database catch { return(false); } return(true); }
public async Task <IActionResult> ConfirmBooking(long bookingId, [FromBody] ConfirmBooking cmd) { try { cmd.BookingId = bookingId; await messaging.Send(cmd); return(StatusCode(200)); } catch (Domain.BookingException e) { return(StatusCode(e.Status, new { e.Message })); } catch (Exception e) { logger.LogError(e, $"{nameof(ConfirmBooking)} error"); return(StatusCode(500)); } }
/// <summary> /// RemoveDetails will remove particular record based on the parameter "id" /// </summary> /// <param name="bookingid"></param> /// <returns>bool</returns> public bool RemoveDetails(int bookingid) { try { //Based on parameter "id" by using .Find method we find entire row ConfirmBooking book = db.booking.Find(bookingid); //.Remove method removes the row of the object db.booking.Remove(book); //Saving changes to database db.SaveChanges(); } //Catch block will hit when there is error while save in database catch { //false will be returned due to error return(false); } //If the savechanges method works then true will be returned return(true); }
public ActionResult ConfirmBooking(BooKingDataForm FormData) { if (FormData.StartDate < FormData.EndDate) { int result = RoomStore.CheckForReservation(FormData); if (result > 0) { RoomDetail RoomData = RoomStore.GetRoomById(result); ConfirmBooking Data = new ConfirmBooking { StartDate = FormData.StartDate, EndDate = FormData.EndDate, Room = new RoomsList { RoomId = RoomData.RoomDetailscode, RoomNum = RoomData.RoomNumber }, Price = RoomStore.RecervationPrice(FormData) }; return(View(Data)); } } return(View()); }