void InitPage(CrudAPI crudapi, UnicontaBaseEntity master) { InitializeComponent(); layoutControl = layoutItems; if (LoadedRow == null) { if (editrow == null) { editrow = CreateNew() as ProjectTaskClientLocal; editrow.SetMaster(master != null ? master : api.CompanyEntity); } frmRibbon.DisableButtons("Delete"); } layoutItems.DataContext = editrow; leEmployee.api = leProject.api = leGroup.api = lePayrollCategory.api = leWorkSpace.api = leFollows.api = crudapi; frmRibbon.OnItemClicked += frmRibbon_OnItemClicked; if (master is Uniconta.DataModel.Project) { liProject.Visibility = Visibility.Collapsed; } else if (master is Uniconta.DataModel.Employee) { liEmployee.Visibility = Visibility.Collapsed; } ProjectCache = api.GetCache(typeof(Uniconta.DataModel.Project)); if (editrow?._Project != null) { var project = api.CompanyEntity.GetCache(typeof(Uniconta.DataModel.Project))?.Get(editrow._Project) as ProjectClient; setTask(project); } }
async void setTask(ProjectClient project, ProjectTaskClientLocal rec) { if (api.CompanyEntity.ProjectTask) { if (project != null) { rec.taskSource = project.Tasks ?? await project.LoadTasks(api); } else { rec.taskSource = null; rec.Task = null; } rec.NotifyPropertyChanged("TaskSource"); } }