private bool AcceptCommandCanExecute(object obj) { var canExecute = OperationTypesDataSource != null && OperationTypesDataSource.Count > 0 && OperationTypesDataSource.Where(x => x.Process != 100 && x.Process != 0).Count() == 0 && OperationTypesDataSource.FirstOrDefault(x => x.Process == 100) != null; return(canExecute); }
private bool AddAdditionalCommandCanExecute(object obj) { if (_isEditable && OperationTypesDataSource != null && OperationTypesDataSource.Count > 0) { return(OperationTypesDataSource.Where(x => x.Id != 1).All(x => x.Process == 100)); } return(false); }
/// <summary> /// Set process state from input IProcessable /// </summary> private void SetProcessValue(IProcessable processable) { if (OperationTypesDataSource != null) { var currentType = OperationTypesDataSource.FirstOrDefault(x => x.Index == processable.Index); if (currentType != null) { currentType.Process = processable.GetProcessed(); } } }
/// <summary> /// Change navigation type bu input TypeId /// </summary> private void ChangeNavigationType(int typeId) { var currentType = OperationTypesDataSource.FirstOrDefault(x => x.IsChecked); if (currentType != null && currentType.Process == 100) { currentType = OperationTypesDataSource.FirstOrDefault(x => x.Id == typeId); if (currentType != null) { currentType.IsChecked = true; } } }
private void AddAdditionalCommandExecute(object obj) { var name = string.Format("Допоміжна {0}", OperationTypesDataSource.Count - 2); var index = OperationTypesDataSource.Count; var item = new NavigationModel(_eventAggregator, 2, name, OperationTypesDataSource.FirstOrDefault(), true) { Index = index }; item.Reset(IsEditable); OperationTypesDataSource.All(x => x.IsChecked = false); OperationTypesDataSource.Add(item); _eventAggregator.GetEvent <PubSubEvent <AdditionalEvent> >().Publish(new AdditionalEvent(2, index)); }
/// <summary> /// Initialize or deinitialize Editor getting editorState /// </summary> private void ChangeNavigationViewState(DetailState summaryState, int?orderId, List <IOrderViewModel> orders) { if (summaryState == DetailState.Create) { IsEditable = true; InitalizeDataCollection(); if (OperationTypesDataSource != null) { foreach (var i in OperationTypesDataSource) { i.Reset(IsEditable); } } OnShowView(); } else if (summaryState == DetailState.Edit && orderId.HasValue) { IsEditable = true; if (orders != null && orders.Count > 0) { var typesSource = new List <NavigationModel>(); int index = 0; foreach (var i in orders) { var basicType = new NavigationModel(_eventAggregator, i.Type, i.ToString(), null, i.Type == 0) { Process = 100, Index = index }; typesSource.Add(basicType); index++; } if (typesSource.FirstOrDefault(x => x.Id == 1) == null) { var manualType = new NavigationModel(_eventAggregator, 1, "Ручна", typesSource.FirstOrDefault()) { Index = typesSource.Count }; typesSource.Add(manualType); } if (typesSource.FirstOrDefault(x => x.Id == 2) == null) { var additionalType = new NavigationModel(_eventAggregator, 2, "Допоміжна", typesSource.FirstOrDefault()) { Index = typesSource.Count }; typesSource.Add(additionalType); } OperationTypesDataSource = new ObservableCollection <NavigationModel>(typesSource); var items = OperationTypesDataSource.Where(x => orders.Select(y => y.Type).Contains(x.Id)); if (items != null && items.Count() > 0) { foreach (var i in items) { i.Process = 100; } } } OnShowView(); } else if (summaryState == DetailState.View && orderId.HasValue) { IsEditable = false; if (orders != null && orders.Count > 0) { var typesSource = new List <NavigationModel>(); int index = 0; foreach (var i in orders) { var basicType = new NavigationModel(_eventAggregator, i.Type, i.ToString(), null, i.Type == 0) { Process = 100, Index = index }; typesSource.Add(basicType); index++; } OperationTypesDataSource = new ObservableCollection <NavigationModel>(typesSource); var items = OperationTypesDataSource.Where(x => orders.Select(y => y.Type).Contains(x.Id)); if (items != null && items.Count() > 0) { foreach (var i in items) { i.Process = 100; } } var status = _directoryManager.LaborStatus.FirstOrDefault(x => x.Identity == orders.FirstOrDefault().StatusId); if (status != null) { _isActive = status.Name == "active"; } } OnShowView(); _canBeCanceled = IsOrderCanBeCanceled(orderId.Value); } else if (summaryState == DetailState.Hide) { OnHideView(); } if (OperationTypesDataSource != null) { var currentType = OperationTypesDataSource.FirstOrDefault(); if (currentType != null) { currentType.IsChecked = true; } } }