public DeletePostVM Edit(DelPostUserVM user, DeletePostVM postVM) { user.User = UserService.userLogedin; try { if (user.User.Id == postVM.Post.UserId) { var post = new DeletePostVM(); post.Post = _context.Posts.SingleOrDefault(p => p.UserId == postVM.Post.UserId); post.Post.Title = postVM.Post.Title; post.Post.Description = postVM.Post.Description; post.Post.Link = postVM.Post.Link; post.Post.Location = postVM.Post.Location; post.Post.Thumbnail = postVM.Post.Thumbnail; post.Post.UpdatedAt = DateTime.Now; post.Post.UpdatedBy = user.User.Name; _context.SaveChanges(); return(post); } throw new NotImplementedException(); } catch (Exception) { throw; } }
public IActionResult Delete(int id) { var post = _postService.GetById(id); var model = new DeletePostVM { PostId = post.Id, PostAuthor = post.User.UserName, PostContent = post.Content }; return(View(model)); }
public DeletePostVM DeletePostPrep(PostAndUserVM postAndUser) { postAndUser.User = UserService.userLogedin; //try //{ if (postAndUser.User != null) { var post = new DeletePostVM(); post.Post = _context.Posts.Single(p => p.Id == postAndUser.Post.Id); return(post); } throw new NotImplementedException(); //} //catch (Exception) //{ // throw; //} }
public IActionResult EditPost1(DelPostUserVM userVM, DeletePostVM postVM) { _service.Edit(userVM, postVM); return(View("EditPost")); }
public IActionResult EditPost(DelPostUserVM userVM, DeletePostVM postVM) // { return(View(postVM)); }