Beispiel #1
0
        /// <summary>
        /// Prepare paged researcher education list model
        /// </summary>
        /// <param name="searchModel">Researcher education search model</param>
        /// <param name="researcher">Researcher</param>
        /// <returns>Researcher education list model</returns>
        public ResearcherEducationListModel PrepareResearcherEducationListModel(ResearcherEducationSearchModel searchModel, Researcher researcher)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            if (researcher == null)
            {
                throw new ArgumentNullException(nameof(researcher));
            }

            //get researcher educations
            //chai
            //var researcherEducations = researcher.ResearcherEducations.OrderByDescending(edu => edu.Degree).ToList();
            var researcherEducations = _researcherService.GetAllResearcherEducations(researcher.Id).ToList();
            //prepare list model
            var model = new ResearcherEducationListModel
            {
                Data = researcherEducations.PaginationByRequestModel(searchModel).Select(education =>
                {
                    //fill in model values from the entity
                    var researcherEducationModel = new ResearcherEducationModel
                    {
                        Id                 = education.Id,
                        ResearcherId       = researcher.Id,
                        DegreeName         = education.Degree.GetAttributeOfType <EnumMemberAttribute>().Value,
                        EducationLevelName = education.EducationLevelName,
                        InstituteName      = education.InstituteName,
                        CountryName        = education.CountryName,
                        GraduationYear     = education.GraduationYear
                    };



                    return(researcherEducationModel);
                }),
                Total = researcherEducations.Count
            };

            return(model);
        }
        public virtual IActionResult ResearcherEducationsSelect(ResearcherEducationSearchModel searchModel)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageResearchers))
            {
                return(AccessDeniedKendoGridJson());
            }

            //try to get a researcher with the specified id
            var researcher = _researcherService.GetResearcherById(searchModel.ResearcherId);

            //?? throw new ArgumentException("No researcher found with the specified id");

            //prepare model
            if (researcher != null)
            {
                var model = _researcherModelFactory.PrepareResearcherEducationListModel(searchModel, researcher);

                return(Json(model));
            }
            else
            {
                return(Json(new ResearcherEducationListModel()));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Prepare Researcher Education search model
        /// </summary>
        /// <param name="searchModel">Researcher Education search model</param>
        /// <param name="researcher">Researcher</param>
        /// <returns>Researcher Education search model</returns>
        protected virtual ResearcherEducationSearchModel PrepareResearcherEducationSearchModel(ResearcherEducationSearchModel searchModel, Researcher researcher)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            if (researcher == null)
            {
                throw new ArgumentNullException(nameof(researcher));
            }

            searchModel.ResearcherId = researcher.Id;

            //prepare page parameters
            searchModel.SetGridPageSize();

            return(searchModel);
        }