Example #1
0
        public virtual void LoadSelectLists(List <int> embargoedCountries, Entities.Company company)
        {
            Countries.Add(new SelectListItem()
            {
                Text     = "No public offer",
                Value    = "",
                Selected = true
            });

            foreach (var country in Persistent.Countries.GetAll())
            {
                if (embargoedCountries.Contains(country.ID))
                {
                    continue;
                }

                var item = new SelectListItem()
                {
                    Value = country.ID.ToString(),
                    Text  = country.Entity.Name
                };

                Countries.Add(item);
            }


            foreach (var item in company.Entity
                     .Equipment
                     .EquipmentItems
                     .Select(e => e.ProductID)
                     .Distinct()
                     .ToList())
            {
                var product = (ProductTypeEnum)item;

                if (CompanyService.IsSellable(product) == false)
                {
                    continue;
                }

                if (CompanyService.CanSellProduct((CompanyTypeEnum)company.CompanyTypeID, product) == false)
                {
                    continue;
                }

                Products.Add(new SelectListItem()
                {
                    Value = ((int)product).ToString(),
                    Text  = product.ToHumanReadable().FirstToUpper()
                });
            }

            foreach (var item in company.Entity
                     .Equipment
                     .EquipmentItems
                     .Select(e => new { ProductID = e.ProductID, Quality = e.Quality })
                     .Distinct()
                     .ToList())
            {
                if (CompanyService.IsSellable((ProductTypeEnum)item.ProductID) == false)
                {
                    continue;
                }


                if (ProductQualities.ContainsKey(item.ProductID.ToString()) == false)
                {
                    ProductQualities.Add(item.ProductID.ToString(), new List <int>());
                }

                ProductQualities[item.ProductID.ToString()].Add(item.Quality);
            }
        }