Exemplo n.º 1
0
        public ActionResult CancelReservation(string id)
        {
            Guid guidID;

            if (!Guid.TryParse(id, out guidID))
            {
                return(HttpNotFound("Invalid reservation"));
            }

            var statusChangeReservations = new StatusChangeInputModel()
            {
                ID     = guidID,
                Status = Status.Cancelled
            };

            try
            {
                var reservation = this.reservationManager.ChangeStatus(statusChangeReservations);
                this.reservations.Update(reservation);
                this.reservations.SaveChanges();

                return(View());
            }
            catch (ArgumentNullException)
            {
                return(HttpNotFound("Reservation not found"));
            }
        }
Exemplo n.º 2
0
        public Reservation ChangeStatus(StatusChangeInputModel reservation)
        {
            var dbReservation = this.reservations.Find(reservation.ID);

            if (dbReservation != null)
            {
                dbReservation.Status = reservation.Status;
                return(dbReservation);
            }

            throw new ArgumentNullException("reservation", "Non existing reservation");
        }
Exemplo n.º 3
0
        public ActionResult ChangeStatus(StatusChangeInputModel reservation)
        {
            try
            {
                var dbReservation = this.reservationManager.ChangeStatus(reservation);
                this.reservations.Update(dbReservation);
                this.reservations.SaveChanges();

                return(PartialView("_ChangeStatus", reservation));
            }
            catch (ArgumentNullException)
            {
                return(RedirectToAction("Index", "Reservations"));
            }
        }