Esempio n. 1
0
        public async Task <List <Discussion> > GetDiscussions(string movieid)
        {
            List <Repository.Models.Discussion> repoDiscussions = await _repo.GetMovieDiscussions(movieid);

            if (repoDiscussions == null)
            {
                Console.WriteLine("ForumLogic.GetDiscussions() was called with a movieid 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 void NoDiscGetDiscussionTopicTest()
        {
            object result;

            RelatedDataSet dataSetA = new RelatedDataSet("JimmyJimerson", "ab10101010", "Theory");

            using (var context = new Repository.Models.Cinephiliacs_DbContext(dbOptions))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                RepoLogic repoLogic = new RepoLogic(context);

                // Test GetDiscussionTopic() without Discussion dependency
                result = repoLogic.GetDiscussionTopic(dataSetA.DiscussionTopic.DiscussionId);
            }

            Assert.Null(result);
        }