public ActionResult Main() { IEnumerable <BookingDTO> bookingDTO = booking.GetBookings(); foreach (var b in bookingDTO) { int daysBetween = (DateTime.Now - b.Time).Hours; if (daysBetween > 48 && b.IsPaid == false) { booking.DeleteBooking(b.Id); } } return(View()); }
/// <summary> /// Delete Booking by using id /// </summary> /// <param name="id"></param> /// <returns></returns> public HttpResponseMessage DeleteBooking(int id) { try { if (id <= 0) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Not a valid booking id")); } else if (Ibooking.DeleteBooking(id) == false) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "No booking found with id " + id.ToString())); } else { Ibooking.DeleteBooking(id); return(Request.CreateResponse(HttpStatusCode.OK, "1 row affected")); } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public ActionResult Cancel(int id, UserViewModel userVM) { BookingDTO bookingDTO = booking.GetBooking(id); if (bookingDTO.IsPaid == true) { booking.MessageAboutCancelIfPaid(bookingDTO.UserEmail, bookingDTO.Id); } else { booking.MessageAboutCancel(bookingDTO.UserEmail, bookingDTO.Id); } booking.DeleteBooking(id); if (bookingDTO.IsPaid == true) { userVM.Id = bookingDTO.UserId; userVM.СashAccount = userVM.СashAccount + bookingDTO.Sum; Mapper.Reset(); Mapper.Initialize(cfg => cfg.CreateMap <UserViewModel, UserDTO>()); var userDTO = Mapper.Map <UserViewModel, UserDTO>(userVM); UserService.UpdateClient(userDTO); } return(RedirectToAction("Bookings")); }
public void DeleteBooking(Booking booking) { _booking.DeleteBooking(booking); }
public ActionResult Refuse(int id, string UserEmail) { booking.DeleteBooking(id); return(RedirectToAction("MyBookingList")); }