public IActionResult Grid(UserGroupSearchModel model) { model = InitializeModel(model); var result = _employeeFacadeApiClient.GetUserGroups(model).Result; return(PartialView(result)); }
private UserDto GetUserForDetails(int userId, bool loadManager) { var userSearchModel = new UserSearchModel { PageSize = int.MaxValue, SortColumn = "Name" }; var user = _employeeApiClient.GetUser(userId).Result; if (loadManager) { var managers = _employeeApiClient.GetUsers(userSearchModel).Result.UserSearchResult.Where(x => x.Id != userId).ToList(); user.ManagerSelectList = SelectedListHelper.GetSelectListForManager(managers, user.ManagerId?.ToString()); } var linkedUserApplicationIds = user.Applications.Select(x => x.ApplicationId).ToList(); var userGroupSearch = new UserGroupSearchModel { PageSize = int.MaxValue, SortColumn = "Name" }; userGroupSearch = _employeeApiClient.GetUserGroups(userGroupSearch).Result; user.UserGroupSelectList = SelectedListHelper.GetSelectListForUserGroup(userGroupSearch.UserGroupSearchResult, user.UserGroupId?.ToString()); var searchWebApplication = new WebApplicationSearchModel { PageSize = int.MaxValue, SortColumn = "Name", SortDirection = "Asc" }; searchWebApplication = _employeeApiClient.GetWebApplications(searchWebApplication).Result; user.ApplicationSelectList = SelectedListHelper.GetApplicationTaskSelectList(searchWebApplication.WebApplicationSearchResult, linkedUserApplicationIds); user.LinkedUserApplicationIds = linkedUserApplicationIds.Select(x => x.ToString()).ToList(); return(user); }
public async Task <UserGroupSearchModel> GetUserGroups(UserGroupSearchModel model) { var url = CRMApiUri + "/UserGroup/GetUserGroups?" + GetFilterString(model); var result = await GetOdataResultFromApi(url); var searchResultCount = 0; if (result.Count != null) { int.TryParse(result.Count.ToString(), out searchResultCount); } model.TotalRows = searchResultCount; model.UserGroupSearchResult.Clear(); try { model.UserGroupSearchResult.AddRange(result.Items.Select(item => JsonConvert.DeserializeObject <UserGroupDto>(item.ToString()))); } catch (Exception e) { Console.WriteLine(e); throw; } return(model); }
private string GetFilterString(UserGroupSearchModel searchModel) { var filterString = string.Empty; if (searchModel != null) { if (!string.IsNullOrWhiteSpace(searchModel.FilterText)) { if (string.IsNullOrWhiteSpace(filterString)) { filterString = ODataFilterConstant.Filter + $"contains(Forename,'{searchModel.FilterText}') eq true"; } else { filterString += $" or contains(Forename,'{searchModel.FilterText}') eq true"; } filterString += $" or contains(Surname,'{searchModel.FilterText}') eq true"; } AddPageSizeNumberAndSortingInFilterString(searchModel, ref filterString); } return(filterString); }
private UserGroupSearchModel InitializeModel(UserGroupSearchModel model) { if (model == null) { model = new UserGroupSearchModel { SortColumn = "Id", SortDirection = "Desc", PageSize = 8, PageNumber = 1 }; } else { if (string.IsNullOrWhiteSpace(model.SortColumn)) { model.SortColumn = "Id"; model.SortDirection = "Desc"; } } model.TargetGridId = "UserGroupGrid"; return(model); }
public async Task <UserGroupSearchModel> GetUserGroups(UserGroupSearchModel model) { return(await _userGroupApiClient.GetUserGroups(model)); }