public void TestMethod1() { var opportunities = new Opportunities(); var result = opportunities.Get().Result; Assert.IsNotNull(result); }
public async Task <HttpResponseMessage> Get([FromUri] OpportunitiesRequestModel model) { var cache = new MemoryCacher(); var list = (List <Dictionary <string, string> >)cache.GetValue(cacheKey); if (list == null) { list = new List <Dictionary <string, string> >(); var opportunities = new Opportunities(); var result = await opportunities.Get(); var items = result; for (var i = 1; i < items.Length; i++) { var dict = new Dictionary <string, string>(); for (var j = 0; j < items[i].Length; j++) { dict.Add(items[0][j], items[i][j]); } list.Add(dict); } cache.Add(cacheKey, list, DateTimeOffset.UtcNow.AddHours(1)); } var filteredList = list; if (model.Intent == OpportunitiesIntents.OppsByAccountName) { filteredList = list.Where(d => CompareAreEqual(d["BusinessAccount"], model.AccountName)).ToList(); } if (model.Intent == OpportunitiesIntents.OppsByTotal) { filteredList = list.Where(d => CompareIsGgreater(d["Total"], model.Amount, model.GreaterOrLessThan)).ToList(); } return(new HttpResponseMessage() { Content = new ObjectContent(typeof(List <Dictionary <string, string> >), filteredList, new JsonMediaTypeFormatter(), new MediaTypeHeaderValue("application/json")) }); }