Beispiel #1
0
        /// <summary>
        /// Returns the HTML of the modal to reschedule a Booking for an specific Booking
        /// </summary>
        /// <param name="bookId">Id of the Booking to Reschedule</param>
        public string GetRescheduleBookModalHtml(string bookId)
        {
            if (string.IsNullOrEmpty(bookId))
            {
                ErrorWriter.InvalidArgumentsError();
                return(Resources.Messages.Error_SolicitudFallida);
            }

            string html;

            try
            {
                var model = new RescheduleBookVM();

                var booking = BC.GetBook(bookId);
                model.booking = booking;

                var otherBookList = BC.GetAllBookings("ACT", serv_id: booking.serv_id).ToList();
                model.otherBookList = otherBookList.Where(x => x.start_date_hour > DateTime.Now).ToList();

                var restList = BC.GetAllBookRest(booking.serv_id).ToList();
                model.restList = restList.Where(x => x.start_date_hour > DateTime.Now).ToList();

                html = PartialView("Partial/_rescheduleBookModal", model).RenderToString();
            }
            catch (Exception e)
            {
                ErrorWriter.ExceptionError(e);
                return(Resources.Messages.Error_SolicitudFallida);
            }

            return(html);
        }
Beispiel #2
0
        public ActionResult RescheduleBook(RescheduleBookVM model)
        {
            if (model == null)
            {
                return(Error_InvalidUrl());
            }
            var    newBook = model.booking;
            string bookId  = newBook.booking_id;

            try
            {
                var isAvailable = CheckBookAvailability(newBook);
                if (isAvailable == null)
                {
                    Error_FailedRequest();
                    return(RedirectToAction("CheckBookings", new { bookId }));
                }
                else if (isAvailable == false)
                {
                    SetErrorMsg("Ya hay una hora agendada para esa hora o hay conflicto con el horario de la tienda, por favor seleccione una diferente");
                    return(RedirectToAction("CheckBookings", new { bookId }));
                }

                Booking apiNewBook = newBook;

                var res = BC.UpdateBooking(apiNewBook);

                if (!res)
                {
                    Error_FailedRequest();
                    return(RedirectToAction("CheckBookings"));
                }
            }
            catch (Exception e)
            {
                ErrorWriter.ExceptionError(e);
                Error_CustomError(e.Message);
                return(RedirectToAction("CheckBookings"));
            }

            string successMsg = "La Reserva fue reagendada con éxito";

            SetSuccessMsg(successMsg);

            return(RedirectToAction("CheckBookings"));
        }