Пример #1
0
        public ActionResult MakeDelivery(int hotelID, PagingParam pagingParam, int productID, int quality)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var hotel = hotelRepository.GetById(hotelID);

            var result = hotelService.CanMakeDeliveries(hotel, SessionHelper.CurrentEntity);

            if (result.IsError)
            {
                return(RedirectBackWithError(result));
            }

            int[] availableProducts = { (int)ProductTypeEnum.Fuel, (int)ProductTypeEnum.ConstructionMaterials };

            CompanyTypeEnum[]             companies = new CompanyTypeEnum[] { CompanyTypeEnum.Manufacturer };
            IQueryable <MarketOfferModel> offers    = marketOfferRepository.GetAvailableOffers(productID, quality, hotel.Region.Country, companies, availableProducts);

            if (offers.Count() > 0)
            {
                offers = offers.Apply(pagingParam);
            }

            var rights = hotelService.GetHotelRigths(hotel, SessionHelper.CurrentEntity);
            var info   = hotelRepository.GetHotelInfo(hotelID, SessionHelper.CurrentEntity.EntityID);
            var vm     = new HotelMakeDeliveryViewModel(info, hotel, rights, offers, pagingParam, quality, productID);

            return(View(vm));
        }