private HomeViewModel BuildViewModelForSubreddit(string subredditName, double sentimentFilterLevel) { try { TrackTelemetryOfRequest(subredditName, sentimentFilterLevel); var homeVM = new HomeViewModel() { SubRedditName = subredditName, SentimentFilter = (int)(sentimentFilterLevel * 10) }; var cogSerKey = _configuration["CogSerKey:InstrumentationKey"]; var redditItems = _redditSentiment.GetRedditItemSentimentModels(cogSerKey, subredditName, sentimentFilterLevel); foreach (var f in redditItems) { homeVM.AddRedditItem(f.Title, f.Score, f.Sentiment, f.LinkUrl, f.DiscussionUrl); } return(homeVM); } catch (Exception ex) { // TODO log error or display error return(new HomeViewModel() { SubRedditName = subredditName, SentimentFilter = (int)(sentimentFilterLevel * 10) }); } }