Esempio n. 1
0
        // GET: Rental/Cancel?rentalId=rentalId
        public ActionResult Cancel(Guid?rentalId)
        {
            if (!rentalId.HasValue)
            {
                return(new HttpStatusCodeResult(400));
            }

            Ausleihe rental = m_rentalRepository.GetRentalById(rentalId.Value);

            if (rental != null)
            {
                // check if user is valid
                if (rental.Kunde.KundenKeyGUID == GetCurrentUserId())
                {
                    m_rentalRepository.CancelRental(rental.AusleiheKeyGUID);
                    return(RedirectToAction("Index", "Rental"));
                }
                return(new HttpUnauthorizedResult());
            }

            return(new HttpStatusCodeResult(400));
        }