internal Blog Edit(int id, Blog updatedBlog) { Blog foundBlog = GetById(id); foundBlog.IsPublished = updatedBlog.IsPublished; foundBlog.Body = updatedBlog.Body; foundBlog.Title = updatedBlog.Title; return(_repo.Edit(foundBlog)); }
internal Blog Edit(int id, Blog updatedBlog) { Blog foundBlog = GetById(id); //NOTE GetById() is already handling our null checking foundBlog.IsPublished = updatedBlog.IsPublished; foundBlog.Body = updatedBlog.Body; foundBlog.Title = updatedBlog.Title; return(_repo.Edit(foundBlog)); }
//EDIT/PUT internal Blog Edit(Blog editBlogs) { Blog original = GetById(editBlogs.blogId); // original.Make = editBlogs.Make != null ? editBlogs.Make : original.Make; // original.Model = editBlogs.Model != null ? editBlogs.Model : original.Model; // original.Year = editBlogs.Year != null ? editBlogs.Year : original.Year; return(_repo.Edit(original)); }
internal Blog Edit(int id, Blog updatedBlog) { Blog foundBlog = GetById(id); // GetById is already handling our null checking for id's foundBlog.IsPublished = updatedBlog.IsPublished; foundBlog.Body = updatedBlog.Body; foundBlog.Title = updatedBlog.Title; // send on foundBlog instead of updatedBlog to limit what can be changed as well as know what key/value to edit return(_repo.Edit(foundBlog)); }
internal Blog Edit(Blog updated) { Blog data = GetById(updated.Id); data.Title = updated.Title != null ? updated.Title : data.Title; data.Body = updated.Body != null ? updated.Body : data.Body; data.imgUrl = updated.imgUrl != null ? updated.imgUrl : data.imgUrl; data.published = updated.published != null ? updated.published : data.published; return(_repo.Edit(data)); }
internal Blog Edit(Blog updatedBlog) { Blog found = Get(updatedBlog.Id); if (found.AuthorId != updatedBlog.AuthorId) { throw new Exception("Invalid Request"); } found.Title = updatedBlog.Title; found.Body = updatedBlog.Body != null ? updatedBlog.Body : found.Body; return(_repo.Edit(found)); }
public Blog Edit(Blog editedBlog, int id) { Blog foundBlog = _repo.GetOne(id); editedBlog.Id = foundBlog.Id; editedBlog.Title = editedBlog.Title == null ? foundBlog.Title : editedBlog.Title; editedBlog.CreatorId = editedBlog.CreatorId == null ? foundBlog.CreatorId : editedBlog.CreatorId; editedBlog.Content = editedBlog.Content == null ? foundBlog.Content : editedBlog.Content; editedBlog.IsPublished = editedBlog.IsPublished == false ? foundBlog.IsPublished : editedBlog.IsPublished; return(_repo.Edit(editedBlog, id)); }
public IActionResult Edit(BlogsViewModel model, int Id, IFormFile NewImage) { if (NewImage != null) { var imageName = FileHelper.SaveFile(NewImage, _fileConfig, FileType.Image, _environment.WebRootPath); //FileHelper.DeleteFile(model.Image, _fileConfig, FileType.Image, _environment.WebRootPath); model.Image = imageName; } var result = _blogsRepository.Edit(model, Id); TempData.AddResult(result); return(RedirectToAction(nameof(Index))); }
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 Edit(Blog editData, string userId) { Blog original = _repo.GetOne(editData.Id); if (original == null) { throw new Exception("Bad Id"); } if (original.CreatorId != userId) { throw new Exception("Not the User : Access Denied"); } _repo.Edit(editData); return(_repo.GetOne(editData.Id)); }
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)); }