Example #1
0
        public ActionResult RentRoom(int hotelID, int quality, int nights)
        {
            var hotel = hotelRepository
                        .Include(h => h.HotelPrice)
                        .Include(h => h.Region)
                        .First(h => h.ID == hotelID);

            var entity = SessionHelper.CurrentEntity;

            using (var trs = transactionScopeProvider.CreateTransactionScope())
            {
                var result = hotelService.CanRentRoom(hotel, quality, nights, entity);
                if (result.IsError)
                {
                    return(RedirectBackWithError(result));
                }

                hotelService.RentRoom(hotel, quality, nights, entity.Citizen);

                trs.Complete();
                AddSuccess("Room has been rented!");
                return(RedirectToAction("Rooms", "Hotel", new { hotelID = hotelID }));
            }
        }