public IActionResult Edit(int id, [Bind("Id,Title,Perex,Content,AuthorId,CreatedAt")] Post post) { if (id != post.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(post); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(post)); }
public ActionResult <Post> Patch(Guid ID, [FromBody] Post post) { try { _ctx.Update(post); return(Ok(post)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw new Exception(); } }
public async Task <IActionResult> Put(int?id, [Bind("ID, Title, Author, Content")] Post post) { if (id != post.ID) { return(NotFound()); } if (ModelState.IsValid) { _context.Update(post); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(GetAll))); } return(View(post)); }
public async Task <IActionResult> Put([FromBody] Post post) { if (!ModelState.IsValid) { return(BadRequest()); } _postsContext.Update(post); try { await _postsContext.SaveChangesAsync(); return(Ok()); } catch (DbUpdateConcurrencyException) { return(NotFound()); } }
public ActionResult <Post> Patch(Guid ID, [FromBody] Post post) { _ctx.Update(post); return(Ok(post)); }