private async Task OnGetSchoolNameAsync(IDialogContext context, IAwaitable <string> result) { var msg = await result; if (msg == "exit" || msg == null) { await context.PostAsync("학교 검색을 나가는 중이에요!"); context.Done <SchoolInfo>(null); } else { selectedSchoolInfo.SchoolName = msg; var searchResults = searcher.Search(selectedSchoolInfo.SchoolType, selectedSchoolInfo.SchoolRegion, selectedSchoolInfo.SchoolName); if (searchResults.Count == 1) { await CheckInfo(context, searchResults.First()); } else if (searchResults.Count > 1) { await context.PostAsync("여러개의 검색결과가 있어요! 정확하게 다시 알려주세요... (검색결과가 15개 이상이면 15개까지만 보여줍니다.)"); var resultMsg = context.MakeMessage(); resultMsg.AttachmentLayout = AttachmentLayoutTypes.Carousel; resultMsg.Attachments = new List <Attachment>(); foreach (var item in searchResults) { HeroCard heroCard = new HeroCard { Title = item.SchoolName, Text = item.SchoolAdress }; resultMsg.Attachments.Add(heroCard.ToAttachment()); } await context.PostAsync(resultMsg); PromptDialog.Text(context, OnGetSchoolNameAsync, "현재 다니는 학교의 이름을 알려주세요! ([ exit ] => 설정 종료)"); } else if (searchResults.Count < 1) { await context.PostAsync("검색결과가 존재하지 않네요... 다시한번 정확히 알려주세요!"); PromptDialog.Text(context, OnGetSchoolNameAsync, "현재 다니는 학교의 이름을 알려주세요! ([ exit ] => 설정 종료)"); } else { await context.PostAsync("검색 중 문제가 발생했어요! :("); context.Done <SchoolInfo>(null); } } }
public Task <JsonResult> OnPostGetName(string count, string page, string name) { if (!int.TryParse(count, out int HowMany)) { return(Task.FromResult(new JsonResult(new { error = "Error" }))); //TODO: Make errors more debug friendly } if (!int.TryParse(page, out int WhatPage)) { return(Task.FromResult(new JsonResult(new { error = "Error" }))); //TODO: Make errors more debug friendly } ISearcher <Tenant> search = new SchoolSearcher(configuration, ref HowMany, ref WhatPage, ref name); search.Search(); var temp_list = new List <object>(); foreach (Tenant x in search.Result) { temp_list.Add(new { x.OfficialName, x.Tag }); } return(Task.FromResult(new JsonResult(new { schools = temp_list, allin = search.MaximumInQueue }))); }