Пример #1
0
        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());
        }
Пример #2
0
 /// <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));
     }
 }
Пример #3
0
        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"));
        }
Пример #4
0
 public void DeleteBooking(Booking booking)
 {
     _booking.DeleteBooking(booking);
 }
Пример #5
0
 public ActionResult Refuse(int id, string UserEmail)
 {
     booking.DeleteBooking(id);
     return(RedirectToAction("MyBookingList"));
 }