예제 #1
0
 private async Task PopulateLists(ChangeHistoryViewModel model)
 {
     model.SuggesterGroups = (await _svc.GetSuggesterGroupsAsync(User)).OrderBy(s => s.Name).Select(s => new SelectListItem {
         Text = s.Name, Value = s.Code
     });
     model.ApproverGroups      = model.SuggesterGroups;
     model.EstablishmentTypes  = (await _lookupService.EstablishmentTypesGetAllAsync()).OrderBy(e => e.Name).Select(e => new LookupItemViewModel(e));
     model.GroupTypes          = (await _lookupService.GroupTypesGetAllAsync()).OrderBy(g => g.Name).Select(g => new LookupItemViewModel(g));
     model.EstablishmentFields = (await _svc.GetEstablishmentFieldsAsync(User)).OrderBy(e => e.Text).Select(s => new StringLookupItemViewModel(s.Key, s.Text));
 }
        private async Task <ActionResult> SearchGroups(GroupSearchViewModel model)
        {
            if (model.SearchType == eSearchType.Group &&
                model.GroupSearchModel.Text.IsNullOrEmpty())
            {
                return(RedirectToSearchPage(model));
            }

            if (model.GroupSearchModel.AutoSuggestValueAsInt.HasValue)
            {
                return(RedirectToDetailPage(model.GroupSearchModel.AutoSuggestValueAsInt.Value));
            }
            else
            {
                model.SearchQueryString = Request.QueryString.ToString();
                var text = model.GroupSearchModel.Text.Clean();
                model.GroupTypes    = (await _lookupService.GroupTypesGetAllAsync()).Select(x => new LookupItemViewModel(x)).ToList();
                model.GroupStatuses = (await _lookupService.GroupStatusesGetAllAsync()).Select(x => new LookupItemViewModel(x)).ToList();

                ApiPagedResult <SearchGroupDocument> results = null;
                if (text != null)
                {
                    results = await _groupReadService.SearchByIdsAsync(text, text.ToInteger(), text, text.ToInteger(), User);
                }

                if (results != null && results.Count > 0)
                {
                    model.Results.Add(results.Items[0]);
                    model.Count = 1;
                }
                else
                {
                    var payload = CreateSearchPayload(model);
                    results = await _groupReadService.SearchAsync(payload, User);

                    model.Results = results.Items;
                    if (model.StartIndex == 0)
                    {
                        model.Count = results.Count;
                    }
                }

                if (model.Count == 1)
                {
                    return(RedirectToDetailPage(model.Results.Single().GroupUId));
                }
                if (model.Count == 0)
                {
                    return(RedirectToSearchPage(model));
                }

                return(View("GroupResults", model));
            }
        }
        private async Task <IEnumerable <int> > GetGroupTypes()
        {
            var types = await _lookupService.GroupTypesGetAllAsync();

            return(types.OrderBy(x => x.Id).Select(x => x.Id));
        }
예제 #4
0
 private async Task <IEnumerable <SelectListItem> > GetAcademyTrustGroupTypes(int?typeId = null)
 => (await _lookup.GroupTypesGetAllAsync()).Where(x => x.Id == (int)GT.MultiacademyTrust || x.Id == (int)GT.SingleacademyTrust).ToSelectList(typeId);