private void FixupCause(Cause previousValue) { if (previousValue != null && previousValue.StoppageReports.Contains(this)) { previousValue.StoppageReports.Remove(this); } if (Cause != null) { if (!Cause.StoppageReports.Contains(this)) { Cause.StoppageReports.Add(this); } } }
private void FixupParent(Cause previousValue) { if (previousValue != null && previousValue.Children.Contains(this)) { previousValue.Children.Remove(this); } if (Parent != null) { if (!Parent.Children.Contains(this)) { Parent.Children.Add(this); } } }
public override void Save(object param) { var cobranches = CauseDataService.GetActives().Where(x => x != _model && x.Parent == _model.Parent); var duplicate = cobranches.FirstOrDefault(x => x.Code == Code); if (duplicate != null) { Code = (byte)(cobranches.Max(x => x.Code) + 1); System.Windows.MessageBox.Show("تمام زیرشاخه های هر علت توقف، بایستی کد منحصر به فرد داشته باشند", duplicate.Name, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); } if (_model.Code > 99) { Code = 99; System.Windows.MessageBox.Show("کد بایستی بین 0 و 99 باشد", Name, System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); } CauseDataService.AttachModel(_model); _model = CauseDataService.GetSingle(_model.Id); OnPropertyChanged("ModifiedBy"); OnPropertyChanged("ModifiedDate"); Mode = ModificationStatus.Saved; }
/// <summary> /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values. /// </summary> public CauseVM(AccessType access, CauseDataService dataService) : base(access) { InitializeData(dataService); _model = new Cause(); }
/// <summary> /// Initializes a new instance of the <see cref="ProductVM"/> class from the model. /// </summary> /// <param name="entity">The model.</param> /// <param name="access"></param> /// <param name="dataService"></param> public CauseVM(Cause entity, AccessType access, CauseDataService dataService) : base(access) { InitializeData(dataService); _model = entity; ParentId = entity.Parent == null ? 0 : entity.Parent.Id; Title = Name; foreach (var child in entity.Children) { if (child.Status != (decimal) Status.Deleted) ChildNodes.Add(new CauseVM(child, Access,dataService)); } }