public PricelistsViewModel() { ServicesViewModel = new PricelistServicesViewModel(); Items.ShapeView().OrderBy(p => p.Caption).Apply(); EditorViewModel = new PricelistEditorViewModel(); EditorViewModel.Save.InvokeCommand(LoadItems); GroupEditorViewModel = new PricelistGroupEditorViewModel(); GroupEditorViewModel.Save.Select(p => 0).InvokeCommand(LoadItems); Copy = ReactiveCommand.Create(() => { var id = EntityManagerService.DefaultPricelistManager.Copy(SelectedItem); LoadItems.Execute(id).Subscribe(); }, canEdit); EditGroup = ReactiveCommand.Create(() => { List <Pricelist> items; if (IsMultiSelect == false) { items = Items.Where(p => p.ID == SelectedItem.ID).ToList(); } else { items = Items.OnlySelected().ToList(); } GroupEditorViewModel.Init(items); }, canMultiEdit); Print = ReactiveCommand.Create(() => { var report = new PricelistReport("Reports/ReportResources/Pricelist.frx"); report.ShowReport(SelectedItem.ID); }, canEdit); this.WhenAnyValue(p => p.SelectedItem) .Where(p => p != null) .Subscribe(p => { ServicesViewModel.Init(0, SelectedItem); }); }
public DiscountlistsViewModel() { ServicesViewModel = new DiscountlistServicesViewModel(); Items.ShapeView().OrderBy(p => p.Caption).Apply(); EditorViewModel = new DiscountlistEditorViewModel(); EditorViewModel.Save.InvokeCommand(LoadItems); GroupEditorViewModel = new DiscountlistGroupEditorViewModel(); GroupEditorViewModel.Save.Select(p => 0).InvokeCommand(LoadItems); Copy = ReactiveCommand.Create(() => { var id = EntityManagerService.DefaultDiscountlistManager.Copy(SelectedItem); LoadItems.Execute(id).Subscribe(); }, canEdit); this.WhenAnyValue(p => p.SelectedItem) .Where(p => p != null) .Subscribe(p => { ServicesViewModel.Init(0, SelectedItem); }); }
public OrdersViewModel() { PeriodFilter = new PeriodFilter(); PeriodFilter.Periods.ForEach(p => p.IsActive = true); PeriodFilter.PeriodChanged.Select(p => 0).InvokeCommand(LoadItems); Items.ShapeView().OrderBy(p => p.InTime).Apply(); Items.ShapeView().GroupBy(p => p.InTime.Date).Apply(); EditorViewModel = new OrderEditorViewModel(); EditorViewModel.Save.Subscribe(id => { if (EditorViewModel.EditingItem.InDate < PeriodFilter.StartDate || EditorViewModel.EditingItem.InDate > PeriodFilter.EndDate) { PeriodFilter.SetManualDate(EditorViewModel.EditingItem.InTime.Date); } LoadItems.Execute(id).Subscribe(); }); SetReady = ReactiveCommand.Create(() => { using (var db = DbService.GetDb()) { var manager = new OrderManager(db); if (IsMultiSelect == false) { manager.ValidateAndSetReadiness(SelectedItem, true); } else { db.BeginTransaction(); manager.SetReadiness(Items.OnlySelected(), true); db.CommitTransaction(); } } }, canMultiEdit); SetReady.Select(p => 0).InvokeCommand(LoadItems); SetReady.ThrownExceptions.Subscribe(async ex => await Interactions.ShowError(ex.Message)); SetUnready = ReactiveCommand.Create(() => { using (var db = DbService.GetDb()) { var manager = new OrderManager(db); if (IsMultiSelect == false) { manager.ValidateAndSetReadiness(SelectedItem, false); } else { db.BeginTransaction(); manager.SetReadiness(Items.OnlySelected(), false); db.CommitTransaction(); } } }, canMultiEdit); SetUnready.Select(p => 0).InvokeCommand(LoadItems); SwitchReadiness = ReactiveCommand.Create(() => { EntityManagerService.DefaultOrderManager.ValidateAndSetReadiness(SelectedItem, !SelectedItem.IsClosed); }, canEdit); SwitchReadiness.Select(p => 0).InvokeCommand(LoadItems); SwitchReadiness.ThrownExceptions.Subscribe(async ex => await Interactions.ShowError(ex.Message)); DaySummaryViewModel = new DaySummaryViewModel(); ShowDaySummary = ReactiveCommand.Create <DateTime>((day) => { DaySummaryViewModel.Init(day); }); Print = ReactiveCommand.CreateFromTask(async() => { if (SelectedItem.IsClosed == false) { await Interactions.ShowError("Заезд не закрыт!"); return; } var report = new OrderForClientReport("Reports/ReportResources/OrderForClient.frx"); report.ShowReport(SelectedItem.ID); }, canEdit); }
public virtual void Init(int id) { LoadItems.Execute(id).Subscribe(); }