public ProjectResearcherListModel PrepareProjectResearcherListModel(ProjectResearcherSearchModel searchModel, Project project) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (project == null) { throw new ArgumentNullException(nameof(project)); } //get researcher educations //chai //var researcherEducations = researcher.ResearcherEducations.OrderByDescending(edu => edu.Degree).ToList(); var projectResearchers = _projectService.GetAllProjectResearchers(project.Id).ToList(); //prepare list model var model = new ProjectResearcherListModel { Data = projectResearchers.PaginationByRequestModel(searchModel).Select(x => { //fill in model values from the entity var projectResearcherModel = new ProjectResearcherModel { Id = x.Id, Portion = x.Portion, ProjectId = x.ProjectId, RoleName = (int)x.ProjectRole != 0 ? x.ProjectRole.GetAttributeOfType <EnumMemberAttribute>().Value : string.Empty, ResearcherId = x.ResearcherId, ProjectRoleId = x.ProjectRoleId, ResearcherName = x.ResearcherName, }; return(projectResearcherModel); }), Total = projectResearchers.Count }; return(model); }
public virtual IActionResult ProjectResearchersSelect(ProjectResearcherSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageProjects)) { return(AccessDeniedKendoGridJson()); } //try to get a project with the specified id var project = _projectService.GetProjectById(searchModel.ProjectId); //?? throw new ArgumentException("No project found with the specified id"); //prepare model if (project != null) { var model = _projectModelFactory.PrepareProjectResearcherListModel(searchModel, project); return(Json(model)); } else { return(Json(new ProjectResearcherListModel())); } }
public virtual ProjectResearcherSearchModel PrepareProjectResearcherSearchModel(ProjectResearcherSearchModel searchModel, Project project) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (project == null) { throw new ArgumentNullException(nameof(project)); } searchModel.ProjectId = project.Id; //prepare page parameters searchModel.SetGridPageSize(); return(searchModel); }