public ActionResult Edit(int id)
        {
            var postForEdit = _postManager.GetById(id);
            var postVm      = Mapper.Map <PostViewModel>(postForEdit);

            return(View(postVm));
        }
Exemple #2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var postDetails = postManager.GetById((int)id);

            if (postDetails == null)
            {
                return(HttpNotFound());
            }

            DetailsPostViewModel detailsPostViewModel = Mapper.Map <DetailsPostViewModel>(postDetails);

            return(View(detailsPostViewModel));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Post          post          = _postManager.GetById((int)id);
            PostViewModel postViewModel = new PostViewModel
            {
                Id         = post.Id,
                Title      = post.Title,
                Details    = post.Details,
                Tags       = post.Tags,
                CatagoryId = post.CatagoryId
            };

            ViewBag.CategoryId = new SelectList(_catagoryManager.GetAll(), "Id", "Name", post.CatagoryId);
            return(View(postViewModel));
        }
        public async Task Update(UpdatePostInput input)
        {
            var entity = await _manager.GetById(input.Id);

            if (entity == null)
            {
                throw new UserFriendlyException($"Post {input.Id} not found");
            }

            if (entity.UserId != AbpSession.UserId)
            {
                throw new UserFriendlyException("Access denied");
            }

            entity.Update(input.Name, input.Content);

            await _manager.Update(entity);
        }
 public Post Get(int id)
 {
     return(_postManager.GetById(id));
 }