예제 #1
0
 public ApiResult <IEnumerable <ApplicantResp> > List(SearchApplicantReqs request)
 {
     try
     {
         SearchApplicantCondition    search     = Mapper.Map <SearchApplicantReqs, SearchApplicantCondition>(request);
         IEnumerable <ApplicantInfo> applicants = _applicantQueryService.Query(search);
         return(new ApiResult <IEnumerable <ApplicantResp> >(ResultStatus.SUCCESS, Mapper.Map <ApplicantInfo, ApplicantResp>(applicants)));
     }
     catch (Exception ex)
     {
         _logger.LogError("查询报名者异常", ex);
         return(new ApiResult <IEnumerable <ApplicantResp> >(ResultStatus.EXCEPTION, Enumerable.Empty <ApplicantResp>(), ex.Message));
     }
 }
예제 #2
0
        public ApiResult <PagedData <ApplicantResp> > SearchApplicant(SearchApplicantReqs request)
        {
            try
            {
                SearchApplicantCondition  search    = Mapper.Map <SearchApplicantReqs, SearchApplicantCondition>(request);
                PagedData <ApplicantInfo> applicant = _applicantQueryService.QueryPaged(search);

                return(new ApiResult <PagedData <ApplicantResp> >(ResultStatus.SUCCESS,
                                                                  Mapper.Map <PagedData <ApplicantInfo>, PagedData <ApplicantResp> >(applicant)));
            }
            catch (Exception ex)
            {
                _logger.LogError("查询报名者异常", ex);
                return(new ApiResult <PagedData <ApplicantResp> >(ResultStatus.EXCEPTION, new PagedData <ApplicantResp>(), ex.Message));
            }
        }
        public IActionResult SearchApplicant(long activityId, [FromQuery] SearchApplicantReqs search)
        {
            search.ActivityId = activityId;

            ApiResult <PagedData <ApplicantResp> > applicantApi = _activityService.SearchApplicant(search);

            if (!applicantApi.Result.Records.Any())
            {
                return(Ok(new PagedData <ApplicantResp>()));
            }

            ApiResult <IEnumerable <DivisionResp> > divisionResult = _divisionService.GetByIds(applicantApi.Result.Records.Select(x => x.DivisionId).ToArray());
            ApiResult <IEnumerable <WizardResp> >   wizards        = _wizardService.GetWizards(applicantApi.Result.Records.Select(x => x.WizardId).ToArray());
            ApiResult <IEnumerable <ActivityResp> > activitys      = _activityService.GetByIds(applicantApi.Result.Records.Select(x => x.ActivityId).ToArray());

            return(Ok(new
            {
                applicantApi.Result.PageNow,
                applicantApi.Result.PageSize,
                applicantApi.Result.TotalCount,
                Records = applicantApi.Result.Records.Select(x =>
                {
                    DivisionResp division = divisionResult.Result.FirstOrDefault(d => d.DivisionId == x.DivisionId);
                    WizardResp wizard = wizards.Result.FirstOrDefault(u => u.WizardId == x.WizardId);
                    ActivityResp activity = activitys.Result.FirstOrDefault(a => a.ActivityId == x.ActivityId);
                    return new
                    {
                        x.ApplicantId,
                        Activity = activity?.Name,
                        WizardName = wizard?.Account,
                        Division = division?.Name,
                        x.ApplyTime,
                        x.Mobile,
                        x.RealName,
                        Status = x.Status.GetName()
                    };
                })
            }));
        }
예제 #4
0
        public ActionResult List(int page = 1, int size = 10)
        {
            var applicantReq = new SearchApplicantReqs()
            {
                PageSize = size,
                PageNow  = page
            };

            if (HttpContext.IsAuthenticated())
            {
                applicantReq.WizardId = HttpContext.User.ExtractUserId();
            }

            ApiResult <IEnumerable <ApplicantResp> > applicantResult = _activityService.List(applicantReq);

            if (applicantResult.Status != ResultStatus.SUCCESS)
            {
                return(Ok(Anonymous.ApiResult(ResultStatus.FAIL, applicantResult.Message)));
            }

            ApiResult <IEnumerable <ActivityResp> > activityResult = _activityService.GetByIds(applicantResult.Result.Select(x => x.ActivityId).ToArray());

            if (activityResult.Status != ResultStatus.SUCCESS)
            {
                return(Ok(Anonymous.ApiResult(ResultStatus.FAIL, activityResult.Message)));
            }

            return(Ok(new ApiResult <object>(ResultStatus.SUCCESS, activityResult.Result.Select(x => new
            {
                x.ActivityId,
                x.Name,
                x.Status,
                x.Type,
                x.Summary,
                x.Thumbnail
            }))));
        }