public SearchVenueByCategoryResult SearchVenueByCategory(VenueSearchCategory input) { SearchVenueByCategoryResult result = new SearchVenueByCategoryResult(); try { if (input.category.Length < 3) { result.result = new BaseResult { isSuccesful = false, resultMessage = "Kategori en az 3 harf olmalıdır" }; return(result); } Core srv = new Core(); var data = srv.SearchVenues(input).Select(a => a.name).ToList(); result.venueList = data; result.result = new BaseResult { isSuccesful = true }; return(result); } catch (Exception ex) { result.result = new BaseResult { isSuccesful = false, resultMessage = ex.Message }; return(result); } }
public List <Venue> SearchVenues(VenueSearchCategory input) { List <Venue> result = new List <Venue>(); FoursquareBusiness.Service srv = new FoursquareBusiness.Service(clientId, clientSecret); List <Parameter> parameters = new List <Parameter>(); if (!string.IsNullOrEmpty(input.category)) { var categoryList = srv.GetVenueCategories(); string categoryId = ""; foreach (var item in categoryList) { foreach (var detailedItem in item.categories) { if (detailedItem.name.Contains(input.category)) { categoryId += item.id + ","; } } } parameters.Add(new Parameter { KeyName = "categoryId", KeyValue = categoryId.Remove(categoryId.Length - 1) }); } if (!string.IsNullOrEmpty(input.location.near)) { parameters.Add(new Parameter { KeyName = "near", KeyValue = input.location.near }); } else { if (!string.IsNullOrEmpty(input.location.latitude) && !string.IsNullOrEmpty(input.location.longtitude)) { parameters.Add(new Parameter { KeyName = "ll", KeyValue = input.location.latitude.Replace(',', '.') + "," + input.location.longtitude.Replace(',', '.') }); } } result = srv.SearchVenues(parameters); return(result); }