Beispiel #1
0
        public TransactionObject CreateNewTopic(NewTopicFormData ntfd)
        {
            TransactionObject response = new TransactionObject();

            try
            {
                Lesson selectedLesson = lessonManager.GetLesson(ntfd.LessonID);
                User   currentUser    = userManager.GetUser(ntfd.UserID);

                Topic newTopic = new Topic();
                newTopic.Name   = ntfd.TopicName;
                newTopic.Lesson = selectedLesson;
                selectedLesson.Topics.Add(newTopic);

                Post post = new Post();
                post.Topic = newTopic;
                newTopic.Posts.Add(post);

                post.Content  = ntfd.Content;
                post.PostDate = DateTime.Now;

                post.Lesson = selectedLesson;
                selectedLesson.Posts.Add(post);

                SentFeeds sf = currentUser.SentFeeds;

                if (sf == null)
                {
                    sf      = new SentFeeds();
                    sf.User = currentUser;
                    currentUser.SentFeeds = sf;
                }
                sf.SentTopics.Add(newTopic);
                newTopic.SentFeed = sf;

                sf.SentPosts.Add(post);
                post.SentFeed = sf;

                if (sf == null)
                {
                    sentFeedManager.AddSentFeed(sf);
                }


                topicManager.AddTopic(newTopic);
                postManager.AddPost(post);
                uow.Save();
                response.IsSuccess   = true;
                response.Explanation = newTopic.ID.ToString();
            }
            catch (Exception ex)
            {
                response.IsSuccess   = false;
                response.Explanation = base.GetExceptionMessage(ex);
            }
            return(response);
        }
Beispiel #2
0
        public TransactionObject SendPost(int topicID, int userID, string postContent)
        {
            TransactionObject response = new TransactionObject();

            try
            {
                Topic currentTopic = topicManager.GetTopic(topicID);
                User  currentUser  = userManager.GetUser(userID);

                SentFeeds sf = currentUser.SentFeeds;

                if (sf == null)
                {
                    sf      = new SentFeeds();
                    sf.User = currentUser;
                    currentUser.SentFeeds = sf;
                    sentFeedManager.AddSentFeed(sf);
                }
                Post newPost = new Post();
                newPost.Topic    = currentTopic;
                newPost.PostDate = DateTime.Now;
                newPost.Content  = postContent;
                newPost.SentFeed = sf;
                newPost.Lesson   = currentTopic.Lesson;
                currentTopic.Lesson.Posts.Add(newPost);

                currentTopic.Posts.Add(newPost);
                currentUser.SentFeeds.SentPosts.Add(newPost);

                postManager.AddPost(newPost);
                uow.Save();


                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess   = false;
                response.Explanation = ex.Message;
            }

            return(response);
        }
 public void DeleteFavouriteFeed(SentFeeds sentFeed)
 {
     sentFeedRepository.Delete(sentFeed);
 }
 public void EditFavouriteFeed(SentFeeds favFeed)
 {
     //favFeedRepository.Update(favFeed);
 }
 public void AddSentFeed(SentFeeds sentFeed)
 {
     sentFeedRepository.Add(sentFeed);
 }