private void LoadData() { if (_customer == null || (_customer != null && _customer.InheritsTimeEntryTypes)) { _dataService.GetGlobalTimeEntryTypes().Subscribe( timeEntryTypes => { var timeEntryTypeViewModels = timeEntryTypes.Select(tt => new TimeEntryTypeViewModel(tt)).ToList(); foreach (var timeEntryTypeViewModel in timeEntryTypeViewModels) { TimeEntryTypes.Add(timeEntryTypeViewModel); } if (DataReady != null) { DataReady(this, null); } } ); } else { LoadCustomerTimeEntryTypes(); } }
//private void CreateTimeEntryTypeCompleted(TimeEntryType newTimeEntryType) //{ // var timeEntryTypeViewModel = new TimeEntryTypeViewModel(newTimeEntryType); // //control the default type // if (newTimeEntryType.IsDefault) // SetAsDefault(newTimeEntryType); // TimeEntryTypes.Add(timeEntryTypeViewModel); // //If its a global type, commit immediately // if (newTimeEntryType.IsGlobal) // Commit(); //} private void EditTimeEntryTypeCompleted(TimeEntryType timeEntryType) { //control the default type if (timeEntryType.IsDefault) { SetAsDefault(timeEntryType); } var timeEntryTypeViewModel = TimeEntryTypes.SingleOrDefault(t => t.TimeEntryType.TimeEntryTypeId == timeEntryType.TimeEntryTypeId); //If its a new one, we´ll add it if (timeEntryTypeViewModel == null) { timeEntryTypeViewModel = new TimeEntryTypeViewModel(timeEntryType); TimeEntryTypes.Add(timeEntryTypeViewModel); if (DataReady != null) { DataReady(this, null); } } //If its a global type, commit immediately if (timeEntryType.Customer == null) { Commit(); } }
private void LoadTimeEntryTypes(TimeEntry timeEntry) { if (_task.Project.Customer.InheritsTimeEntryTypes) { _dataService.GetGlobalTimeEntryTypes().Subscribe( timeEntryTypes => { foreach (var timeEntryType in timeEntryTypes) { TimeEntryTypes.Add(timeEntryType); } if (timeEntry.TimeEntryType == null) { SelectedTimeEntryType = TimeEntryTypes.FirstOrDefault(tt => tt.IsDefault); } //SelectedTimeEntryType = // TimeEntryTypes.SingleOrDefault( // tt => tt.TimeEntryTypeId == TimeEntry.TimeEntryTypeId); OnPropertyChanged("SelectedTimeEntryType"); } ); } else { TimeEntryTypes = _task.Project.Customer.TimeEntryTypes; } }
private void LoadCustomerTimeEntryTypes() { var timeEntryTypeViewModels = _customer.TimeEntryTypes.Select(t => new TimeEntryTypeViewModel(t)).ToList(); foreach (var timeEntryTypeViewModel in timeEntryTypeViewModels) { TimeEntryTypes.Add(timeEntryTypeViewModel); } if (DataReady != null) { DataReady(this, null); } }