public IActionResult Edit(int Id) { var model = _blogsRepository.GetById(Id); if (model == null) { TempData.AddResult(ServiceResult.Error("مقاله ای یافت نشد!")); return(View(nameof(Index))); } return(View(model)); }
internal Blog Edit(Blog editBlog, string userEmail) { Blog original = _repo.GetById(editBlog.Id); if (original == null) { throw new Exception("Invalid Id"); } if (original.CreatorEmail != userEmail) { throw new Exception("Access Denied... This is not yours"); } editBlog.Name = editBlog.Name == null ? original.Name : editBlog.Name; editBlog.Description = editBlog.Description == null ? original.Description : editBlog.Description; editBlog.Img = editBlog.Img == null ? original.Img : editBlog.Img; return(_repo.Edit(editBlog)); }
internal Blog GetById(int id) { Blog foundBlog = _repo.GetById(id); if (foundBlog == null) { throw new Exception("Invalid id."); } return(foundBlog); }
internal Blog GetById(int id) { Blog data = _repo.GetById(id); if (data == null) { throw new Exception("Invalid Id"); } return(data); }
internal Blog GetById(int id) { Blog blog = _repo.GetById(id); if (blog == null) { throw new Exception("Invalid Blog Id"); } return(blog); }
public Blog GetById(int id) { Blog foundBlog = _repo.GetById(id); if (foundBlog == null) { throw new Exception("No blog by that ID"); } return(foundBlog); }
internal Blog Edit(Blog Update) { Blog exists = _repo.GetById(Update.Id); if (exists == null) { throw new Exception("Invalid Request"); } if (exists.CreatorId != Update.CreatorId) { throw new Exception("Cannot edit things you did not create"); } return(_repo.Edit(Update)); }
internal Blog Get(int id) { return(_repo.GetById(id)); }