コード例 #1
0
        public void Init(ISession dbSession, uint promotionId)
        {
            var promotion = dbSession.Query <ProducerPromotion>()
                            .First(r => r.Id == promotionId);

            MarketingEventId   = promotion.MarketingEvent.Id;
            MarketingEventName = promotion.MarketingEvent.Name;
            PromotionId        = promotionId;
            PromotionName      = promotion.Name;
            SupplierId         = promotion.MarketingEvent.Association.Supplier.Id;
            SupplierName       = promotion.MarketingEvent.Association.Supplier.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());
            var regionMask  = (ulong?)promotion.MarketingEvent.Association.Regions.Select(r => r.Region.Id).Distinct().Sum(x => (decimal)x);

            if (regionMask.HasValue)
            {
                AvailablePrices = GetPricesList(dbSession, producerIds, (ulong)regionMask);
            }

            SelectedPriceIds  = string.Join(",", AvailablePrices.Select(r => r.PriceId).ToArray());
            AvailableProducts = GetProductsList(dbSession, producerIds, SelectedPriceIds);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        protected override void OnInitialize()
        {
            base.OnInitialize();

            Catalogs = CatalogTerm
                       .Throttle(Consts.TextInputLoadTimeout, Scheduler)
                       .Select(t => RxQuery(s => {
                if (String.IsNullOrEmpty(t))
                {
                    return(new List <Catalog>());
                }
                if (CurrentCatalog.Value != null && CurrentCatalog.Value.FullName == t)
                {
                    return(Catalogs.Value);
                }

                return(s.CreateSQLQuery(@"
(select {c.*}, 0 as Score
from Catalogs c
where c.Fullname like :term)
union distinct
(select {c.*}, 1 as Score
from Catalogs c
where c.Fullname like :fullterm)
order by Score, {c.FullName}")
                       .AddEntity("c", typeof(Catalog))
                       .SetParameter("term", t + "%")
                       .SetParameter("fullterm", "%" + t + "%")
                       .List <Catalog>()
                       .ToList());
            }))
                       .Switch()
                       .ToValue(CloseCancellation);
            IsCatalogOpen = Catalogs.Select(v => v != null && v.Count > 0).Where(v => v).ToValue();

            Producers = ProducerTerm
                        .Throttle(Consts.TextInputLoadTimeout, Scheduler)
                        .Select(t => RxQuery(s => {
                if (String.IsNullOrEmpty(t))
                {
                    return(new List <Producer>());
                }
                if (CurrentProducer.Value != null && CurrentProducer.Value.Name == t)
                {
                    return(Producers.Value);
                }

                CurrentProducer.Value = null;
                return(s.CreateSQLQuery(@"
(select {p.*}, 0 as Score
from Producers p
where p.Name like :term)
union distinct
(select {p.*}, 1 as Score
from Producers p
where p.Name like :fullterm)
order by Score, {p.Name}")
                       .AddEntity("p", typeof(Producer))
                       .SetParameter("term", t + "%")
                       .SetParameter("fullterm", "%" + t + "%")
                       .List <Producer>()
                       .ToList());
            }))
                        .Switch()
                        .ToValue(CloseCancellation);
            IsProducerOpen = Producers.Select(v => v != null && v.Count > 1).Where(v => v).ToValue();
        }