Пример #1
0
        protected override void OnInitialize()
        {
            base.OnInitialize();
            Lines.Changed.Subscribe(_ => {
                if (Lines.Count > 0)
                {
                    Status.Value = (checkType == CheckType.SaleBuyer ? "Открыт чек продажи" : "Открыт возврат по чеку");
                }
                else
                {
                    Status.Value = "Готов к работе(F1 для справки)";
                    CheckLinesForReturn.Clear();
                    checkType = null;
                }
                CheckSum.Value   = Lines.Sum(x => x.RetailSum);
                DiscontSum.Value = Lines.Sum(x => x.DiscontSum);
            });

            var lines = Shell.SessionContext.GetValueOrDefault(GetType().Name + "." + nameof(Lines)) as ReactiveCollection <CheckLine>;

            if (lines != null)
            {
                Lines.AddRange(lines);
            }
            Shell.SessionContext[GetType().Name + "." + nameof(Lines)] = null;

            CurrentLine
            .SelectMany(x => Env.RxQuery(s => {
                if (x == null)
                {
                    return(null);
                }
                var catalogId = x.CatalogId;
                return(s.Query <Catalog>()
                       .Fetch(c => c.Name)
                       .ThenFetch(n => n.Mnn)
                       .FirstOrDefault(c => c.Id == catalogId));
            }))
            .Subscribe(CurrentCatalog, CloseCancellation.Token);
        }