Exemplo n.º 1
0
        // GET: Posts
        public ActionResult Index()
        {
            var post = new TopicPostViewModel();

            post.PostList = repPost.Read().ToList();
            return(View(post));
        }
Exemplo n.º 2
0
        public ActionResult Details([Bind(Include = "ID,UsersID")] Comments comment, int?id)
        {
            if (ModelState.IsValid)
            {
                repComment.Create(comment);
                return(RedirectToAction("Index"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var topic = new TopicPostViewModel();

            topic.TopicList   = repTopic.Read().Where(x => x.ID == id).ToList();
            topic.PostList    = repPost.Read().ToList();
            topic.CommentList = repComment.Read().ToList();

            if (topic == null)
            {
                return(HttpNotFound());
            }
            return(View(topic));
        }
Exemplo n.º 3
0
        // GET: Topics
        public ActionResult Index()
        {
            var tp = new TopicPostViewModel();

            tp.TopicList = repTopic.Read().ToList();
            tp.PostList  = repPost.Read().ToList();
            return(View(tp));
        }
Exemplo n.º 4
0
        public TopicPostViewModel GetTopicPostById(int topicId)
        {
            TopicPostViewModel model = new TopicPostViewModel();

            try
            {
                TopicPost topicPost = PostManager.GetTopicById(topicId);
                model = ObjectMapper.Map <Model.Entities.TopicPost, TopicPostViewModel>(topicPost);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
            }
            return(model);
        }
Exemplo n.º 5
0
        public int AddTopicPost(TopicPostViewModel topicPost)
        {
            try
            {
                TopicPost _topicPost = ObjectMapper.Map <TopicPostViewModel, TopicPost>(topicPost);

                TopicPost newTopicPost = PostManager.Add(_topicPost);
                return(newTopicPost.Id);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex, PolicyNameType.ExceptionReplacing);
                return(0);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Add a new topic post to the database
        /// </summary>
        /// <param name="title">Post title</param>
        /// <param name="body">Post content</param>
        /// <param name="topicId">Topic id</param>
        /// <param name="currentUserId">Id of the user currently logged in</param>
        /// <returns>Id of the new TopicPost</returns>
        public int AddNewTopicPost(string title, string body, int topicId, int currentUserId)
        {
            TopicPostViewModel model = new TopicPostViewModel();

            model.Title          = title;
            model.Body           = body;
            model.DateCreated    = DateTime.Now;
            model.PostedByUserId = currentUserId;
            model.TopicId        = topicId;
            int newTopicPost = AddTopicPost(model);

            // Assign the newly created TopicPost to discussion's LatestPostId
            UpdateLatestPostForDiscussion(topicId, newTopicPost);

            return(newTopicPost);
        }
Exemplo n.º 7
0
        // GET: Posts/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var postLi = new TopicPostViewModel();


            Post post = repPost.Read().FirstOrDefault(x => x.ID == id);

            if (post == null)
            {
                return(HttpNotFound());
            }
            return(View(post));
        }
Exemplo n.º 8
0
        // GET: Topics/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var topic = new TopicPostViewModel();

            topic.TopicList   = repTopic.Read().Where(x => x.ID == id).ToList();
            topic.PostList    = repPost.Read().ToList();
            topic.CommentList = repComment.Read().ToList();

            if (topic == null)
            {
                return(HttpNotFound());
            }
            return(View(topic));
        }