public void SetData(ISession dbSession, uint promotionId) { ProductListGet = new PromotionTableSelectorViewModel <ViewModelListItem>(); ProductListSet = new PromotionTableSelectorViewModel <ViewModelListItem>(); SupplierListGet = new PromotionTableSelectorViewModel <ViewModelRegionListItem>(); SupplierListSet = new PromotionTableSelectorViewModel <ViewModelRegionListItem>(); //RegionList = dbSession.Query<Region>().OrderBy(s => s.Name).Select(s => new SelectListItem() { Text = s.Name, Value = s.Id.ToString() }).ToList(); RegionList = new List <ViewModelListItem>(); Promotion = dbSession.Query <ProducerPromotion>().First(s => s.Id == promotionId); SuppliersType = Promotion.SuppliersType; var currentProducts = string.Join(",", Promotion.Products.Select(s => s.Product.Id).ToList()); var currentSupplier = string.Join(",", Promotion.Suppliers.Select(s => s.Supplier.Id).ToList()); ProductListGet.SetData(dbSession, promotionId, PromotionTableRequestType.ProductsListToGet, currentProducts, ""); ProductListSet.SetData(dbSession, promotionId, PromotionTableRequestType.ProductsListToSet, currentProducts, ""); SupplierListGet.SetData(dbSession, promotionId, PromotionTableRequestType.SuppliersListToGet, currentSupplier, ""); SupplierListSet.SetData(dbSession, promotionId, PromotionTableRequestType.SuppliersListToSet, currentSupplier, ""); ProductsListToSetList = string.Join(",", ProductListSet.ItemsList.Select(s => s.Value)); SuppliersListToSetList = string.Join(",", SupplierListSet.ItemsList.Select(s => s.Value)); }
public void Init(ISession dbSession, uint promotionId) { SupplierListGet = new PromotionTableSelectorViewModel <ViewModelRegionListItem>(); SupplierListSet = new PromotionTableSelectorViewModel <ViewModelRegionListItem>(); RegionList = new List <ViewModelListItem>(); var promotion = dbSession.Query <ProducerPromotion>() .First(r => r.Id == promotionId); SuppliersType = promotion.SuppliersType; MarketingEventId = promotion.MarketingEvent.Id; MarketingEventName = promotion.MarketingEvent.Name; PromotionId = promotionId; PromotionName = promotion.Name; Producers = promotion.MarketingEvent.Producers.Select(r => r.Producer).ToList(); SelectedProductIds = string.Join(",", promotion.Products.Select(r => r.Product.Id.ToString()).ToArray()); var producerIds = string.Join(",", Producers.Select(r => r.Id.ToString()).ToArray()); AvailableProducts = GetProductsList(dbSession, producerIds); var currentSupplier = string.Join(",", promotion.Suppliers.Select(s => s.Supplier.Id).ToList()); SupplierListGet.SetData(dbSession, promotionId, PromotionTableRequestType.SuppliersListToGet, currentSupplier, ""); SupplierListSet.SetData(dbSession, promotionId, PromotionTableRequestType.SuppliersListToSet, currentSupplier, ""); SuppliersListToSetList = string.Join(",", SupplierListSet.ItemsList.Select(s => s.Value)); }