public void RemoveUser(User user) { var userToRemove = SelectedUsers.SingleOrDefault(u => u.User.UserID == user.UserID); if (userToRemove != null) { if (_timeEntryFilter != null) { _timeEntryFilter.RemoveUser(user); } SelectedUsers.Remove(userToRemove); OnPropertyChanged("SelectedUsers"); OnPropertyChanged("HasConsultants"); } }
/// <summary> /// If user does not have a forecastmonth registration /// the server will not return anytning. /// Generate "dummy" line, so missing registrations are visible /// </summary> /// <param name="month"></param> /// <param name="year"></param> /// <param name="response"></param> public virtual void TryAddMissingUsers(int month, int year, ForecastSearchResponse response) { var responsedUsersIds = response.ForecastMonths.Select(x => x.UserId).ToList(); var requestedUserIds = SelectedUsers.Where(x => !x.IsAllUsers).Select(x => x.UserId).ToList(); var userEmptyResult = requestedUserIds.Where(x => responsedUsersIds.All(y => y != x)); foreach ( var user in userEmptyResult.Select(userId => SelectedUsers.SingleOrDefault(x => x.UserId == userId)) // Select the local user-object .Where(user => user != null)) { response.ForecastMonths.Add(new ForecastMonthDto { UserId = user.UserId, UserName = user.Name, CreatedById = 0, Id = 0, IsLocked = false, Month = month, Year = year, ForecastDtos = new Collection <ForecastDto>() }); } }