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);
        }
Beispiel #2
0
        /// <summary>
        /// Maps an instance of Repository.Models.Discussion and an instance of
        /// Repository.Models.Topic onto a new instance of GlobalModels.Discussion
        /// </summary>
        /// <param name="repoDiscussion"></param>
        /// <param name="topic"></param>
        /// <returns></returns>
        public static Discussion RepoDiscussionToDiscussion(Repository.Models.Discussion
                                                            repoDiscussion, Repository.Models.Topic topic)
        {
            var discussion = new Discussion(repoDiscussion.DiscussionId, repoDiscussion.MovieId,
                                            repoDiscussion.Username, repoDiscussion.Subject, topic.TopicName);

            return(discussion);
        }
Beispiel #3
0
        public async Task <bool> CreateDiscussion(NewDiscussion discussion)
        {
            var repoDiscussion = Mapper.NewDiscussionToNewRepoDiscussion(discussion);
            var repoTopic      = new Repository.Models.Topic();

            repoTopic.TopicName = discussion.Topic;
            return(await _repo.AddDiscussion(repoDiscussion, repoTopic));
        }
        internal RelatedDataSet(string username, string movieId, string topicName)
        {
            User             = new Repository.Models.User();
            User.Username    = username;
            User.FirstName   = "Jimmy";
            User.LastName    = "Jimerson";
            User.Email       = "*****@*****.**";
            User.Permissions = 1;

            Movie         = new Repository.Models.Movie();
            Movie.MovieId = movieId;

            Review              = new Repository.Models.Review();
            Review.MovieId      = movieId;
            Review.Username     = username;
            Review.Rating       = 4.0m;
            Review.CreationTime = DateTime.Now;

            Topic           = new Repository.Models.Topic();
            Topic.TopicName = movieId;

            Discussion = new Repository.Models.Discussion();
            Discussion.DiscussionId = 1;
            Discussion.MovieId      = movieId;
            Discussion.Username     = username;
            Discussion.CreationTime = DateTime.Now;
            Discussion.Subject      = "This movie doesn't exist.";

            Comment              = new Repository.Models.Comment();
            Comment.CommentId    = 1;
            Comment.DiscussionId = 1;
            Comment.Username     = username;
            Comment.CreationTime = DateTime.Now;
            Comment.CommentText  = "This movie is UNREAL!";
            Comment.IsSpoiler    = true;

            DiscussionTopic = new Repository.Models.DiscussionTopic();
            DiscussionTopic.DiscussionId = 1;
            DiscussionTopic.TopicName    = topicName;

            FollowingMovie          = new Repository.Models.FollowingMovie();
            FollowingMovie.Username = username;
            FollowingMovie.MovieId  = movieId;
        }
Beispiel #5
0
        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);
        }