Exemple #1
0
        public RedirectToActionResult AddPost(string postTitle, string postContent, string threadId, string userId)
        {
            // Build post object
            // Get thread by id
            // add post to thread
            // make a temp data entry containing the userId
            // redirect to ReloadBlogDashboard action method

            Post newPost = new Post()
            {
                PostID    = ObjectIDBuilder.GetPostID(),
                Title     = postTitle,
                Content   = postContent,
                TimeStamp = DateTime.Now
            };

            int THREADID = int.Parse(threadId);

            threadRepo.GetThreadById(THREADID).AddPostToThread(newPost);

            TempData["userId"] = userId;
            return(RedirectToAction("ReloadBlogDashboard"));
        }
Exemple #2
0
        public IActionResult PostEditor(string postId, string threadId, string userId)
        {
            // NOTE: object IDs are passed in via viewbag because there we don't want to build DB retrieval logic into the view
            // Get thread repo by id
            // Find post by id from thread
            // Pass postObject into view
            // Pass userId into view by Viewbag
            int  POST_ID    = int.Parse(postId);
            int  THREAD_ID  = int.Parse(threadId);
            Post postToEdit = threadRepo.GetThreadById(THREAD_ID).GetPostById(POST_ID);

            ViewBag.ThreadId = threadId;
            ViewBag.UserId   = userId;
            return(View(postToEdit));
        }
Exemple #3
0
        public IActionResult ViewBlog(int threadID = -1)
        {
            Thread searchResult;

            if (threadID != -1)
            {
                // search for the thread by name
                searchResult = threadRepo.GetThreadById(threadID);
            }
            else
            {
                // returns to thread page if no parameter values are found
                return(View("Index"));
            }
            return(View(searchResult));
        }
        public IActionResult GetById(int threadID)
        {
            Thread searchResult;

            // search for the thread by name
            searchResult = threadRepo.GetThreadById(threadID);
            if (searchResult != null)
            {
                return(Ok(searchResult));
            }
            else
            {
                return(NotFound());
            }

            /*else
             * {
             *  // returns to thread page if no parameter values are found
             *  return View("Index");
             * }
             * return View(searchResult);*/
        }