private async void PremiseSettingChangedExecute(object obj) { var list = new List <IUserWLanTimeEntryType>(); list.AddRange(_userWlanSettingsService.WLansBoundToTimeEntryTypes); var availableNetworkList = await _connectivityService.GetAvailableNetworkList(); var unlistedWLanTimeEntryTypes = availableNetworkList .Select(x => new UserWLanTimeEntryType(0, x)) .Where(newWlans => list.All(x => x.WifiName != newWlans.WifiName)); list.AddRange(unlistedWLanTimeEntryTypes); foreach (var userWLanTimeEntryType in list) { userWLanTimeEntryType.Connected = userWLanTimeEntryType.WifiName == await _connectivityService.GetWLanIdentification(); } WLansBoundToTimeEntryTypes.Clear(); WLansBoundToTimeEntryTypes.AddRange(list.Select(x => { var timeEntryTypes = TimeEntryTypes.SingleOrDefault(t => t.Id == x.DefaultTimeEntryTypeId); return(new UserWLanTimeEntryTypeItemViewmodel(timeEntryTypes, x)); })); WLansBoundToTimeEntryTypes.ItemChanged += WLansBoundToTimeEntryTypesOnCollectionChanged; }
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(); } }
public void Commit() { foreach (var timeEntryTypeModel in TimeEntryTypes) { _dataService.SaveTimeEntryType(timeEntryTypeModel.TimeEntryType).Subscribe( timeEntryType => { var timeEntryTypeViewModel = TimeEntryTypes.SingleOrDefault( t => t.TimeEntryType.TimeEntryTypeId == timeEntryType.TimeEntryTypeId); if (timeEntryTypeViewModel != null) { timeEntryTypeViewModel.TimeEntryType.TimeEntryTypeId = timeEntryType.TimeEntryTypeId; } timeEntryTypeModel.Update(); }); } if (DataCommitted != null) { DataCommitted(this, null); } }
public void Reload() { TimeEntryTypes.Clear(); LoadData(); EditTimeEntry.RaiseCanExecuteChanged(); CreateTimeEntry.RaiseCanExecuteChanged(); }
//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; } }
protected virtual void ClearNavigationProperties() { CustomerInvoiceGroups.Clear(); User = null; TimeEntryTypes.Clear(); Projects.Clear(); Tags.Clear(); UsersCustomers.Clear(); Users = null; }
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); } }
private TimeEntryType GetMostUsedTimeEntryType(DayItemHeaderViewmodel dayItemHeaderViewmodel) { var timeEntries = dayItemHeaderViewmodel.TimeEntries .ToList(); if (!timeEntries.Any()) { return(TimeEntryTypes.SingleOrDefault(x => x.IsDefault)); // Can be empty if resync is in progress } var mostUsedTimeEntryType = timeEntries .GroupBy(x => x.TimeEntryType.Id) .OrderByDescending(x => x.Count()) .First().Key; return(TimeEntryTypes.SingleOrDefault(x => x.Id == mostUsedTimeEntryType)); // Can be empty if resync is in progress }
private async void LoadTimeEntries() { _busyService.ShowBusy(_reportscreenKey); List <TimeEntry> timeEntries = null; try { timeEntries = await _timeEntryService.GetTimeEntriesByDate(FromDate, ToDate); } catch (Exception ex) { if (!_isShowingTextbox) { _isShowingTextbox = true; var result = MessageBox.Show("Error loading timeentries", "Error", MessageBoxButton.OK); _isShowingTextbox = result == MessageBoxResult.None; } Logger.Error(ex); } try { ReportCommands.DataLoaded.Execute(null); if (timeEntries != null) { var gridRowViewModels = timeEntries.Select(timeEntry => { TimeEntryType timeEntryType = null; if (TimeEntryTypes != null) { var @default = TimeEntryTypes.FirstOrDefault(x => x.IsDefault); timeEntryType = timeEntry.TimeEntryType == null ? @default : TimeEntryTypes.FirstOrDefault(x => x.Id == timeEntry.TimeEntryType.Id); } return(new GridRowItemViewModel(timeEntry, timeEntryType)); }); GridRows = new ObservableCollection <GridRowItemViewModel>(gridRowViewModels); } } catch (Exception ex) { Logger.Error(ex); } _busyService.HideBusy(_reportscreenKey); }
public DesignHistoryFeedViewModel() { UserDefaultTimeEntryType = TimeEntryTypes.First(); }
private void SetAsDefault(TimeEntryType timeEntryType) { TimeEntryTypes.ToList().ForEach(t => t.IsDefault = false); timeEntryType.IsDefault = true; }