public IActionResult Search([FromQuery] PagedSearch search) { ApiResult <PagedData <WizardResp> > wizards = _wizardService.Search(new SearchWizardReqs() { PageSize = search.PageSize, PageNow = search.PageNow, IsAdmin = true }); ApiResult <IEnumerable <DivisionResp> > divisions = _divisionService.GetByIds(wizards.Result.Records.Select(x => x.DivisionId).Distinct().ToArray()); IEnumerable <CityResponse.City> cities = _cityService.Find(x => ((long)x.id).IsIn(divisions.Result.Select(o => o.CityId).Distinct())); return(Ok(new { wizards.Result.PageNow, wizards.Result.PageSize, wizards.Result.TotalCount, Records = wizards.Result.Records.Select(x => { DivisionResp division = divisions.Result.FirstOrDefault(o => o.DivisionId == x.DivisionId); CityResponse.City city = cities.FirstOrDefault(c => c.id == division.CityId); return new { x.WizardId, x.DivisionId, City = city?.nm, x.Account, x.Email, x.CreateTime, }; }) })); }
public IActionResult Search([FromQuery] SearchActivityModel model) { SearchActivityReqs search = Mapper.Map <SearchActivityModel, SearchActivityReqs>(model); ApiResult <PagedData <ActivityResp> > activitys = _activityService.Search(search); ApiResult <IEnumerable <DivisionResp> > divisionResult = _divisionService.GetByIds(activitys.Result.Records.Select(x => x.DivisionId).ToArray()); ApiResult <IEnumerable <WizardResp> > wizards = _wizardService.GetWizards(activitys.Result.Records.Select(x => x.CreatorId).ToArray()); return(Ok(new { activitys.Result.PageNow, activitys.Result.PageSize, activitys.Result.TotalCount, Records = activitys.Result.Records.Select(x => { DivisionResp division = divisionResult.Result.FirstOrDefault(d => d.DivisionId == x.DivisionId); WizardResp creator = wizards.Result.FirstOrDefault(u => u.WizardId == x.CreatorId); return new { x.ActivityId, x.DivisionId, x.Name, x.BeginTime, x.FinishTime, x.RegistrationBeginTime, x.RegistrationFinishTime, Status = x.Status.GetName(), Division = division?.Name, Creator = creator?.Account }; }) })); }
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() }; }) })); }