public async Task <List <Discussion> > GetDiscussions(string username) { List <Repository.Models.Discussion> repoDiscussions = await _repo.GetUserDiscussions(username); if (repoDiscussions == null) { Console.WriteLine("UserLogic.GetDiscussions() was called for a username that doesn't exist"); return(null); } List <Discussion> discussions = new List <Discussion>(); foreach (var repoDiscussion in repoDiscussions) { // Get the topic associated with this discussion Repository.Models.Topic topic = _repo.GetDiscussionTopic(repoDiscussion.DiscussionId); if (topic == null) { topic = new Repository.Models.Topic(); topic.TopicName = "None"; } discussions.Add(Mapper.RepoDiscussionToDiscussion(repoDiscussion, topic)); } return(discussions); }
public async Task <Discussion> GetDiscussion(int discussionid) { Repository.Models.Discussion repoDiscussion = await _repo.GetDiscussion(discussionid); if (repoDiscussion == null) { Console.WriteLine("ForumLogic.GetDiscussion() was called for an invalid discussionid."); return(null); } // Get the topic associated with this discussion Repository.Models.Topic topic = _repo.GetDiscussionTopic(repoDiscussion.DiscussionId); if (topic == null) { topic = new Repository.Models.Topic(); topic.TopicName = "None"; } Discussion discussion = Mapper.RepoDiscussionToDiscussion(repoDiscussion, topic); return(discussion); }