public ActionResult ViewPostsByUserId(int userId) { List <PostDO> postList = null; List <PostPO> displayList = null; PostViewModel postVM = new PostViewModel(); ActionResult response = null; try { postList = _dataAccess.ViewPostsByUserId(userId); displayList = PostMapper.ListDOToPO(postList); postVM.Posts = displayList; //Sets the response to the view which contains the post view model's info response = View(postVM); } catch (Exception ex) { Logger.Log("Fatal", ex.TargetSite.ToString(), ex.Message, ex.StackTrace); } return(response); }
public ActionResult Index() { ActionResult response = null; List <PostDO> postList = null; List <PostPO> displayList = null; PostViewModel postVM = new PostViewModel(); try { //sets postList to the ViewAllPosts method in UserDAO then maps and displays it postList = _dataAccess.ViewAllPosts(); displayList = PostMapper.ListDOToPO(postList); postVM.Posts = displayList; response = View(postVM); } catch (Exception ex) { Logger.Log("Fatal", ex.TargetSite.ToString(), ex.Message, ex.StackTrace); } return(response); }
public float AverageWordsPerPost() { List <PostDO> postList = null; List <PostPO> displayList = null; float averageWords = 0; try { //gets a list of posts to count the words in the content of all posts postList = _postDataAccess.ViewAllPosts(); displayList = PostMapper.ListDOToPO(postList); List <PostBO> ListToBofromPo = PostMapper.ListPOToBO(displayList); //sets the number of words in the posts to a variable averageWords = _ThreadBLL.AverageWordsPerPost(ListToBofromPo); } catch (Exception ex) { Logger.Log("Fatal", ex.TargetSite.ToString(), ex.Message, ex.StackTrace); } return(averageWords); }
public ActionResult ViewPostsByThreadId(int threadId) { List <PostDO> postList = null; List <PostPO> displayList = null; PostViewModel postVM = new PostViewModel(); postVM.ThreadId = threadId; ActionResult response = null; try { postList = _dataAccess.ViewPostsByThreadId(threadId); displayList = PostMapper.ListDOToPO(postList); //Uses a post view model which holds the list of posts and the thread ID postVM.Posts = displayList; response = View(postVM); } catch (Exception ex) { Logger.Log("Fatal", ex.TargetSite.ToString(), ex.Message, ex.StackTrace); } return(response); }