Beispiel #1
0
        public IActionResult Search([FromQuery] SearchSessionReqs search)
        {
            ApiResult <PagedData <SessionResp> > sessionApi = _sessionService.SearchSession(search);

            if (sessionApi.Status != ResultStatus.SUCCESS)
            {
                return(Ok(new PagedData <SessionResp>()));
            }

            if (sessionApi.Result.TotalCount == 0)
            {
                return(Ok(new PagedData <SessionResp>()));
            }

            ApiResult <IEnumerable <DivisionResp> >         divisions    = _divisionService.GetByIds(sessionApi.Result.Records.Select(x => x.DivisionId).ToArray());
            ApiResult <IEnumerable <Remote.Models.Cinema> > cinemas      = _cinemaService.GetByIds(sessionApi.Result.Records.Select(x => x.CinemaId));
            ApiResult <IEnumerable <ActivityResp> >         activityList = _activityService.GetByIds(sessionApi.Result.Records.Select(x => x.ActivityId).ToArray());
            ApiResult <IEnumerable <Hall> > hallList = _hallService.GetByIds(sessionApi.Result.Records.Select(o => o.HallId));

            return(Ok(new
            {
                sessionApi.Result.PageNow,
                sessionApi.Result.PageSize,
                sessionApi.Result.TotalCount,
                Records = sessionApi.Result.Records.Select(x =>
                {
                    DivisionResp division = divisions.Result.FirstOrDefault(o => o.DivisionId == x.DivisionId);
                    Remote.Models.Cinema cinema = cinemas.Result.FirstOrDefault(o => o.CinemaId == x.CinemaId);
                    ActivityResp activity = activityList.Result.FirstOrDefault(o => o.ActivityId == x.ActivityId);
                    Hall hall = hallList.Result.FirstOrDefault(o => o.HallId == x.HallId);
                    return new
                    {
                        x.SessionId,
                        Division = division?.Name,
                        Cinema = cinema?.Name,
                        Hall = hall?.Name,
                        Activity = activity?.Name,
                        StatusDesc = x.Status.GetName(),
                        Status = x.Status,
                    };
                })
            }));
        }
        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()
                    };
                })
            }));
        }