private void InitializeData() { UnitOfWork = new SoheilEdmContext(); CauseDataService = new CauseDataService(UnitOfWork); CauseDataService.CauseAdded += OnCauseAdded; CauseDataService.CauseUpdated += OnCauseUpdated; AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems); AddGroupCommand = new Command(Add, CanAddGroup); ViewCommand = new Command(View, CanView); CreateItems(null); }
/// <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(); }
private void InitializeData(CauseDataService dataService) { CauseDataService = dataService; SaveCommand = new Command(Save, CanSave); ChildNodes = new ObservableCollection<IEntityNode>(); }
public static Cause CreateNew(CauseDataService dataService, int parentId, CauseLevel level) { int id = dataService.AddModel(new Cause { Name = "جدید", Code = 0, Description = string.Empty, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, Level = (byte) level, Status = (byte) Status.Active}, parentId); return dataService.GetSingle(id); }
/// <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)); } }