public ActionResult DeleteBooking(CancelBookingViewModel booking) { try { if (ModelState.IsValid) { ClientDTO client = new ClientDTO { Name = booking.Name, Surname = booking.Surname, BirthDate = booking.BirthDate }; ClientDTO newClient = clientService.GetClientByInfo(client); var bookingDTO = new BookingDTO { HotelID = booking.HotelID, RoomNumber = booking.RoomNumber, ClientID = newClient.ClientID, StartDate = booking.StartDate, EndDate = booking.EndDate, PeopleQuantity = booking.PeopleQuantity }; bookingService.CancelBooking(bookingDTO); ViewBag.SuccessMsg = "Successfully canceled booking."; return(View(booking)); } } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); ViewBag.CancelError = ex.Message; return(View(booking)); } return(View(booking)); }
public ActionResult DeleteBooking(int?id) { try { var hotel = hotelService.GetHotel(id); var cancelBooking = new CancelBookingViewModel { HotelID = hotel.HotelID, HotelName = hotel.Name }; return(View(cancelBooking)); } catch (ValidationException ex) { return(Content(ex.Message)); } }
public async Task CancelBooking() { if (!String.IsNullOrEmpty(CancelBookingRequest.Email)) { var result = await Http.PutAsJsonAsync($"{Configuration["BaseApiUrl"]}api/v1.0/booking/{CancelBookingRequest.BookingNumber}/cancel", CancelBookingRequest.Email.ToLower()); if (result.IsSuccessStatusCode) { Toast.ShowToast($"You have canceled your booking with the booking number {CancelBookingRequest.BookingNumber}", ToastLevel.Success); CancelBookingRequest = new CancelBookingViewModel(); StateHasChanged(); } else { Toast.ShowToast("Cant find your email, please enter your correct email", ToastLevel.Error); } } else { Toast.ShowToast("Please enter your email", ToastLevel.Error); } }
public ActionResult Cancel([FromBody] CancelBookingViewModel input) { return(Manager.CancelBooking(input.Id, input.CancelledAt, input.CancelledReason) ? StatusCode((int)HttpStatusCode.OK) : StatusCode((int)HttpStatusCode.BadRequest)); }