public ActionResult Index(int page = 0, string authorId = null) { var authors = GetUsersByRoleName("author"); var entities = authorId != null ? _postManager.Get(x => !x.IsBlocked && x.AuthorId == authorId).Reverse() : _postManager.Get(x => !x.IsBlocked); var mostViewedData = entities.OrderByDescending(x => x.UsersReadCount).Take(MOST_VIEWED).ToList(); var mostViewed = _mapper.Map <IList <PostViewModel> >(mostViewedData); var count = entities.Count(); var data = entities.Reverse().Skip(page * PAGE_SIZE).Take(PAGE_SIZE).ToList(); var entitiesMap = _mapper.Map <IList <PostViewModel> >(data); var result = new AllPostsViewModel { Posts = entitiesMap, MostViewed = mostViewed, Authors = authors, Page = page, MaxPage = (count / PAGE_SIZE) - (count % PAGE_SIZE == 0 ? 1 : 0), AuthorId = authorId }; return(View(result)); }
//[HttpPost] //public ActionResult Delete(int inquiryId) //{ // Response<Inquiry> r = _inquiryManager.Get(inquiryId); // if (!r.Success) // { // SetErrorTempData(r.Message); // } // if (ModelState.IsValid) // { // var manager = new InquiryManager(); // manager.Delete(inquiryId); // //Return View Needs to be Changed // return View("ManageInquiry",""); // } // //Also Needs to be changed // return View("ManageInquiry"); //} public ActionResult BlogPost(int id) { Response <Post> r = _postManager.Get(id); if (!r.Success) { SetErrorViewData(r.Message); } return(View(r.Data)); }
public IActionResult RemovePost(int id) { PostDto post = _postManager.Get(id); _postManager.Remove(id); var deleteObj = new { id, postStatus = "Deleted" }; return(Json(deleteObj)); }
// GET: api/Post/5 public PostDetailsModel Get(int id) { return(_postManager.Get(id)); }
public void ManagerCanGetPostById() { var actual = _postManager.Get(1); Assert.AreEqual(1, actual.Data.Id); }
public async Task <PostDTO> Get(long id) { var post = await postManager.Get(id); return(mapper.Map <PostDTO>(post)); }
// GET: api/Post/5 public Post Get(int id) { return(_postManager.Get(id).Data); }