public Task <IEnumerable <Result> > getResult() { using (var webClient = new System.Net.WebClient()) { string rawJSON = webClient.DownloadString("https://localhost:44388/api/votes"); //string rawJSON = webClient.DownloadString("http://dmitrogeras-eval-test.apigee.net/votesystem/api/votes"); CollectionResults collectionResults = JsonConvert.DeserializeObject <CollectionResults>(rawJSON); IEnumerable <Result> res = collectionResults.Resuts; return(Task.FromResult(res)); } }
public async Task <CollectionResults> Get() { List <Vote> votess = await _votesService.GetVotesList(); List <Result> r = new List <Result>(); CollectionResults collectionResults = new CollectionResults(); var result = (votess.GroupBy(v => v.Candidate_id, (key, group) => new { candidate_id = key, count = group.ToList().Count })); foreach (var item in result) { r.Add(new Result(item.candidate_id, item.count)); } collectionResults.Resuts = r; return(collectionResults); }