示例#1
0
        public async Task <ActionResult> LoadTable()
        {
            var applicant = await ApplicantService.GetApplicants();

            var res = Mapper.Map <IEnumerable <Applicant>, IEnumerable <ApplicantFormModel> >(applicant);

            return(View(res));
        }
示例#2
0
        public ActionResult LoadApplicants(int count)
        {
            // Используем Task.Run, а не await потому что PartialView не умеет работать с Async/Await
            var applicants = Task.Run(() => ApplicantService.GetApplicants()).Result;

            ViewBag.IdName   = "list-applicant";
            ViewBag.SizeList = "18";

            if (count < 1)
            {
                return(PartialView("_PartialDefaultList", new BaseFormModel[] {}));
            }

            if (count > applicants.Count())
            {
                count = applicants.Count();
            }

            applicants = applicants.Skip(applicants.Count() - count);
            var result = Mapper.Map <IEnumerable <Applicant>, IEnumerable <BaseFormModel> >(applicants);

            return(PartialView("_PartialDefaultList", result));
        }
 protected override async Task OnInitializedAsync()
 {
     Applicants = (await ApplicantService.GetApplicants()).ToList();
 }