예제 #1
0
        public ActionResult MarketOffers(int countryID, PagingParam pagingParam, int productID, int quality)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var country = countryRepository.GetById(countryID);

            if (country == null)
            {
                return(RedirectToHomeWithError("Country does not exist!"));
            }
            int[] availableProducts = { (int)ProductTypeEnum.Bread, (int)ProductTypeEnum.MovingTicket, (int)ProductTypeEnum.Tea, (int)ProductTypeEnum.Weapon };

            CompanyTypeEnum[]             companies = new CompanyTypeEnum[] { CompanyTypeEnum.Shop };
            IQueryable <MarketOfferModel> offers    = marketOfferRepository.GetAvailableOffers(productID, quality, country, companies, availableProducts);

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

            var countries = countryRepository.GetAll().ToList();


            var vm = new CountryMarketOffersListViewModel(SessionHelper.CurrentEntity, country, offers.ToList(), countries, availableProducts, pagingParam, quality, productID);

            return(View(vm));
        }
예제 #2
0
        public ActionResult ResourceOffers(int countryID, PagingParam pagingParam, int productID, int quality)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var country = countryRepository.GetById(countryID);

            if (country == null)
            {
                return(RedirectToHomeWithError("Country does not exist!"));
            }


            int[] availableProducts = { (int)ProductTypeEnum.Bread,    (int)ProductTypeEnum.MovingTicket, (int)ProductTypeEnum.Tea,                (int)ProductTypeEnum.Weapon, ProductTypeEnum.Fuel.ToInt(),
                                        ProductTypeEnum.Grain.ToInt(), ProductTypeEnum.Iron.ToInt(),      ProductTypeEnum.MedicalSupplies.ToInt(), ProductTypeEnum.Oil.ToInt(), ProductTypeEnum.TeaLeaf.ToInt(),ProductTypeEnum.Wood.ToInt(),
                                        ProductTypeEnum.Paper.ToInt(), ProductTypeEnum.ConstructionMaterials.ToInt() };

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

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

            var countries = countryRepository.GetAll().ToList();


            var vm = new CountryMarketOffersListViewModel(SessionHelper.CurrentEntity, country, offers.ToList(), countries, availableProducts, pagingParam, quality, productID);

            return(View("MarketOffers", vm));
        }
예제 #3
0
        public HouseBuyCMViewModel(House house, PagingParam pp, IQueryable <MarketOfferModel> offers, HouseRights houseRights)
        {
            Info = new HouseInfoViewModel(house, houseRights);

            Market = new CountryMarketOffersListViewModel(
                SessionHelper.CurrentEntity,
                SessionHelper.LoggedCitizen.Region.Country,
                offers.ToList(),
                Persistent.Countries.GetAll().ToList(),
                new List <int>()
            {
                (int)ProductTypeEnum.ConstructionMaterials,
                (int)ProductTypeEnum.UpgradePoints
            },
                pp,
                1,
                (int)ProductTypeEnum.ConstructionMaterials);
        }
예제 #4
0
        public HotelMakeDeliveryViewModel(HotelInfo info, Hotel hotel, HotelRights rights, IQueryable <MarketOfferModel> offers,
                                          PagingParam pp, int quality, int productID)
        {
            Info = new HotelInfoViewModel(info);
            WalletIDs.Add(SessionHelper.CurrentEntity.WalletID, "Your wallet");
            if (rights.CanUseWallet)
            {
                WalletIDs.Add(hotel.Entity.WalletID, "Hotel's wallet");
            }

            Market = new CountryMarketOffersListViewModel(hotel.Entity, hotel.Region.Country, offers.ToList(),
                                                          Persistent.Countries.GetAll().ToList(),
                                                          new List <int>()
            {
                (int)ProductTypeEnum.Fuel,
                (int)ProductTypeEnum.ConstructionMaterials
            }, pp,
                                                          quality,
                                                          productID);
        }
예제 #5
0
        public ActionResult Houses(int countryID, PagingParam pagingParam)
        {
            pagingParam = pagingParam ?? new PagingParam();

            var country = countryRepository.GetById(countryID);

            if (country == null)
            {
                return(RedirectToHomeWithError("Country does not exist!"));
            }


            int[] availableProducts = { (int)ProductTypeEnum.House };

            CompanyTypeEnum[]             companies = new CompanyTypeEnum[] { CompanyTypeEnum.Construction };
            IQueryable <MarketOfferModel> offers    = marketOfferRepository.GetAvailableOffers((int)ProductTypeEnum.House, 1, country, companies, availableProducts);

            if (SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen))
            {
                offers = offers.Where(o => o.CompanyRegionID == SessionHelper.LoggedCitizen.RegionID);
            }

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

            var countries = countryRepository.GetAll().ToList();

            var vm = new CountryMarketOffersListViewModel(SessionHelper.CurrentEntity, country, offers.ToList(), countries, availableProducts, pagingParam, 1, (int)ProductTypeEnum.House);

            vm.DisableShowingQuantity();
            vm.QualityList = new List <SelectListItem>();

            return(View("MarketOffers", vm));
        }