public async Task <IHttpActionResult> SearchSelection([FromBody] SearchSelectionInput json)
        {
            try
            {
                if (json.SelectionId == "province") // استان
                {
                    var provinceList = await _provinceService.SearchProvinceAsync(json.SearchText, json.Limit);

                    var buttonSimpleList = new List <ButtonSimpleModel>();
                    foreach (var province in provinceList)
                    {
                        buttonSimpleList.Add(new ButtonSimpleModel
                        {
                            Type     = ButtonSimpleTypeEnum.TextOnly,
                            Text     = province.Name,
                            ImageUrl = null
                        });
                    }

                    return(Ok(new { items = buttonSimpleList }));
                }

                if (json.SelectionId == "city")  // شهر
                {
                    var account = await _userInfoService.GetUserInfo(json.ChatId);

                    //var userProvince = await _provinceService.GetProvinceAsync(account.ProvinceName);
                    var cityList = await _provinceService.SearchCityAsync(account.ProvinceId.Value, json.SearchText, json.Limit);

                    var buttonSimpleList = new List <ButtonSimpleModel>();
                    foreach (var city in cityList)
                    {
                        buttonSimpleList.Add(new ButtonSimpleModel
                        {
                            Type     = ButtonSimpleTypeEnum.TextOnly,
                            Text     = city.Name,
                            ImageUrl = null
                        });
                    }

                    return(Ok(new { items = buttonSimpleList }));
                }


                if (json.SelectionId == "bank")
                {
                    var bankList = await _bankService.SearchBank(json.SearchText, json.Limit);

                    var buttonSimpleList = new List <ButtonSimpleModel>();
                    foreach (var bank in bankList)
                    {
                        buttonSimpleList.Add(new ButtonSimpleModel
                        {
                            Type     = ButtonSimpleTypeEnum.TextOnly,
                            Text     = bank.Name,
                            ImageUrl = null
                        });
                    }

                    return(Ok(new { items = buttonSimpleList }));
                }


                return(CustomResult());
            }
            catch (Exception exception)
            {
                return(CustomError(exception));
            }
        }
Exemple #2
0
        public async Task <IHttpActionResult> SearchSelection([FromBody] SearchSelectionInput json)
        {
            try
            {
                if (json.SelectionId == "provinces") // استان
                {
                    var provinceList = await _provinceService.SearchProvinceAsync(json.SearchText, json.Limit);

                    var buttonSimpleList = new List <ButtonSimpleModel>();
                    foreach (var province in provinceList)
                    {
                        buttonSimpleList.Add(new ButtonSimpleModel
                        {
                            Type     = ButtonSimpleTypeEnum.TextOnly,
                            Text     = province.Title,
                            ImageUrl = null
                        });
                    }

                    return(Ok(new { items = buttonSimpleList }));
                }
                if (json.SelectionId == "axes")
                {
                    var list = await _festivalService.SearchFestivalAxesListAsync(json.SearchText.PersianToEnglish(), json.Limit);

                    //var list = await _candidateService.SearchCandidateAsync(userInfo.StateName, json.SearchText, json.Limit);
                    var buttonSimpleList = new List <ButtonSimpleModel>();
                    foreach (var item in list)
                    {
                        buttonSimpleList.Add(new ButtonSimpleModel
                        {
                            Type     = ButtonSimpleTypeEnum.TextOnly,
                            Text     = $"{item.Title}",
                            ImageUrl = null
                        });
                    }

                    return(Ok(new { items = buttonSimpleList }));
                }

                if (json.SelectionId == "fields")
                {
                    var info = await _groupService.GetGroupInfo(json.ChatId);

                    var list = await _festivalService.SearchFestivalFieldsListAsync(info.FestivalAxId.Value, json.SearchText.PersianToEnglish(), json.Limit);

                    //var list = await _candidateService.SearchCandidateAsync(userInfo.StateName, json.SearchText, json.Limit);
                    var buttonSimpleList = new List <ButtonSimpleModel>();
                    foreach (var item in list)
                    {
                        buttonSimpleList.Add(new ButtonSimpleModel
                        {
                            Type     = ButtonSimpleTypeEnum.TextOnly,
                            Text     = $"{item.Title}",
                            ImageUrl = null
                        });
                    }

                    return(Ok(new { items = buttonSimpleList }));
                }

                if (json.SelectionId == "majors")
                {
                    var info = await _groupService.GetGroupInfo(json.ChatId);

                    var list = await _festivalService.SearchFestivalMajorsListAsync(info.FestivalFieldId.Value, json.SearchText.PersianToEnglish(), json.Limit);

                    //var list = await _candidateService.SearchCandidateAsync(userInfo.StateName, json.SearchText, json.Limit);
                    var buttonSimpleList = new List <ButtonSimpleModel>();
                    foreach (var item in list)
                    {
                        buttonSimpleList.Add(new ButtonSimpleModel
                        {
                            Type     = ButtonSimpleTypeEnum.TextOnly,
                            Text     = $"{item.Title}",
                            ImageUrl = null
                        });
                    }

                    return(Ok(new { items = buttonSimpleList }));
                }

                return(CustomResult());
            }
            catch (Exception exception)
            {
                return(CustomError(exception));
            }
        }