public IActionResult Edit(Guid id, [Bind("ID,Url")] Blog blog) { if (id != blog.ID) { return(NotFound()); } if (ModelState.IsValid) { try { blogsService.Update(blog); } catch (DbUpdateConcurrencyException) { if (!BlogExists(blog.ID.ToString())) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(blog)); }
public ActionResult UpdateBlog(string id, [FromHeader] string password, [FromBody] Blog newBlog) { if (password != "rockrockwhite") { return(BadRequest(new Response <string>(new PasswordError()) { resultBody = "" })); } var blog = _blogsService.Get(id); if (blog == null) { return(NotFound(new Response <string>(new BlogIdError()) { resultBody = "" })); } _blogsService.Update(id, newBlog); return(Ok(new Response <Blog>(new Ok()) { resultBody = blog })); }
public ActionResult <Blog> Update(int id, [FromBody] Blog updatedBlog) { try { return(Ok(_blogsService.Update(id, updatedBlog))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
public async Task <ActionResult <Blog> > Update([FromBody] Blog edit, int id) { try { Account userInfo = await HttpContext.GetUserInfoAsync <Account>(); edit.Id = id; Blog update = _service.Update(edit, userInfo.Id); return(Ok(update)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task <ActionResult <Blog> > Update(int id, [FromBody] Blog update) { try { Account userInfo = await HttpContext.GetUserInfoAsync <Account>(); // _rService.Update(id, userInfo.Id); update.CreatorId = userInfo.Id; update.Id = id; Blog updated = _bService.Update(update); return(Ok(updated)); } catch (Exception e) { return(BadRequest(e.Message)); } }