private void InitializeData() { WorkProfilePlanDataService = new WorkProfilePlanDataService(); WorkProfilePlanDataService.WorkProfilePlanAdded += OnWorkProfilePlanAdded; ColumnHeaders = new List<ColumnInfo> { new ColumnInfo("Name",0, false), new ColumnInfo("StartDate",1, false), new ColumnInfo("EndDate",2, false), new ColumnInfo("SelectedProfile.Name", "txtWorkProfile",3, true), }; AddCommand = new Command(Add, CanAdd); RefreshCommand = new Command(CreateItems); AddGroupCommand = new Command(Add, CanAddGroup); ResetCommand = new Command(Reset, CanReset); CreateItems(null); }
/// <summary> /// Initializes a new instance of the <see cref="WorkProfilePlanVm"/> class initialized with default values. /// </summary> public WorkProfilePlanVm(AccessType access, WorkProfilePlanDataService dataService) : base(access) { _model = dataService.CreateDefault(); InitializeData(dataService); }
public static WorkProfilePlan CreateNew(WorkProfilePlanDataService dataService) { int id = dataService.AddModel(dataService.CreateDefault()); return dataService.GetSingle(id); }
private void InitializeData(WorkProfilePlanDataService dataService) { WorkProfilePlanDataService = dataService; SaveCommand = new Command(Save, CanSave); //add all profiles foreach (var profile in new WorkProfileDataService().GetAll()) { Profiles.Add(new WorkProfileInfo(profile)); } if (_model != null) if (_model.WorkProfile != null) SelectedProfile = Profiles.FirstOrDefault(x => x.Id == _model.WorkProfile.Id); }
/// <summary> /// Initializes a new instance of the <see cref="WorkProfilePlanVm"/> class from the model. /// </summary> /// <param name="entity">The model.</param> /// <param name="access"></param> /// <param name="dataService"></param> public WorkProfilePlanVm(WorkProfilePlan entity, AccessType access, WorkProfilePlanDataService dataService) : base(access) { _model = entity; InitializeData(dataService); }