Exemple #1
0
        public async Task <WebApplicationSearchModel> GetWebApplications(WebApplicationSearchModel model)
        {
            var url    = CRMApiUri + "/WebApplication/GetWebApplications?" + 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.WebApplicationSearchResult.Clear();
            try
            {
                model.WebApplicationSearchResult.AddRange(result.Items.Select(item => JsonConvert.DeserializeObject <WebApplicationDto>(item.ToString())));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(model);
        }
Exemple #2
0
        public IActionResult Grid(WebApplicationSearchModel model)
        {
            model = InitializeModel(model);
            var result = _employeeFacadeApiClient.GetWebApplications(model).Result;

            return(PartialView(result));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        private TaskDto GetTaskDetails(int taskId)
        {
            var task = _taskApiClient.GetTask(taskId).Result;
            var linkedApplicationIds = task.ApplicationTasks.Select(x => x.ApplicationId).ToList();

            var searchWebApplication = new WebApplicationSearchModel {
                PageSize = int.MaxValue, SortColumn = "Name", SortDirection = "Asc"
            };

            searchWebApplication          = _webApplicationApiClient.GetWebApplications(searchWebApplication).Result;
            task.ApplicationSelectList    = SelectedListHelper.GetApplicationTaskSelectList(searchWebApplication.WebApplicationSearchResult, linkedApplicationIds);
            task.LinkedApplicationTaskIds = linkedApplicationIds.Select(x => x.ToString()).ToList();
            return(task);
        }
Exemple #5
0
        private string GetFilterString(WebApplicationSearchModel 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);
        }
Exemple #6
0
 private WebApplicationSearchModel InitializeModel(WebApplicationSearchModel model)
 {
     if (model == null)
     {
         model = new WebApplicationSearchModel
         {
             SortColumn    = "Id",
             SortDirection = "Desc",
             PageSize      = 8,
             PageNumber    = 1
         };
     }
     else
     {
         if (string.IsNullOrWhiteSpace(model.SortColumn))
         {
             model.SortColumn    = "Id";
             model.SortDirection = "Desc";
         }
     }
     model.TargetGridId = "WebApplicationGrid";
     return(model);
 }
Exemple #7
0
        private CalendarSearchModel GetCalendarTaskModel(UserPersonTaskDto userPersonTask = null)
        {
            var model = new UserSearchModel {
                PageSize = int.MaxValue
            };

            model = _employeeFacadeApiClient.GetUsers(model).Result;
            //var personSearch = new PersonSearchModel { PageSize = int.MaxValue };
            //personSearch = _personApiClient.GetPersons(personSearch).Result;
            var taskTypeSearchmodel = new TaskTypeSearchModel {
                PageSize = int.MaxValue
            };

            taskTypeSearchmodel = _taskTypeApiClient.GetTaskTypes(taskTypeSearchmodel).Result;
            var selectedTaskTypeId = taskTypeSearchmodel.TaskTypeSearchResult.FirstOrDefault(x => x.Name == userPersonTask?.TaskTypeSelected)?.Id;
            var taskTypes          = taskTypeSearchmodel.TaskTypeSearchResult?.ConvertAll(x => (BaseLookupDto)x);

            var applications = new WebApplicationSearchModel {
                PageSize = int.MaxValue
            };

            applications = _employeeFacadeApiClient.GetWebApplications(applications).Result;



            var userCalendarModel = new CalendarSearchModel
            {
                ApplicationList = SelectedListHelper.GetApplicationSelectList(applications.WebApplicationSearchResult, userPersonTask?.ApplicationId.ToString()),
                EmployeeList    = SelectedListHelper.GetUserSelectList(model.UserSearchResult, userPersonTask?.UserId.ToString()),
                TaskTypes       = taskTypeSearchmodel.TaskTypeSearchResult,
                TaskTypeList    = SelectedListHelper.GetSelectListForItems(taskTypes, selectedTaskTypeId?.ToString()),
                TaskTypeId      = selectedTaskTypeId,
                //PersonList = SelectedListHelper.GetPersonSelectList(personSearch.PersonSearchResult, userPersonTask?.PersonId.ToString())
            };

            return(userCalendarModel);
        }
Exemple #8
0
 public async Task <WebApplicationSearchModel> GetWebApplications(WebApplicationSearchModel model)
 {
     return(await _webApplicationApiClient.GetWebApplications(model));
 }