コード例 #1
0
        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));
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: isiah18/CMS-Project
        //[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));
        }
コード例 #3
0
        public IActionResult RemovePost(int id)
        {
            PostDto post = _postManager.Get(id);

            _postManager.Remove(id);

            var deleteObj = new
            {
                id,
                postStatus = "Deleted"
            };

            return(Json(deleteObj));
        }
コード例 #4
0
 // GET: api/Post/5
 public PostDetailsModel Get(int id)
 {
     return(_postManager.Get(id));
 }
コード例 #5
0
        public void ManagerCanGetPostById()
        {
            var actual = _postManager.Get(1);

            Assert.AreEqual(1, actual.Data.Id);
        }
コード例 #6
0
ファイル: PostDTOManager.cs プロジェクト: Zbyszard/NTP
        public async Task <PostDTO> Get(long id)
        {
            var post = await postManager.Get(id);

            return(mapper.Map <PostDTO>(post));
        }
コード例 #7
0
ファイル: PostController.cs プロジェクト: isiah18/CMS-Project
 // GET: api/Post/5
 public Post Get(int id)
 {
     return(_postManager.Get(id).Data);
 }