public async Task <ActionResult <PostThis> > Post(PostThis postThis) { await _dbcustom.PostThese.AddAsync(postThis); await _dbcustom.SaveChangesAsync(); return(CreatedAtAction(nameof(Get), new { id = postThis.Id }, postThis)); }
public async Task <ActionResult <PostThis> > Get(int id) { PostThis postThis = await _dbcustom.PostThese.FindAsync(id); if (postThis == null) { return(NotFound()); } return(postThis); }
public async Task <ActionResult <PostThis> > Delete(int id) { PostThis _postthisdb = await _dbcustom.PostThese.FindAsync(id); if (_postthisdb == null) { return(NotFound()); } if (id != _postthisdb.Id) { return(BadRequest()); } _dbcustom.PostThese.Remove(_postthisdb); await _dbcustom.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult <PostThis> > Put(int id, PostThis postThis) { PostThis _postthisdb = await _dbcustom.PostThese.FindAsync(id); if (_postthisdb == null) { return(NotFound()); } if (id != _postthisdb.Id) { return(BadRequest()); } _postthisdb.Tittle = postThis.Tittle; _postthisdb.Content = postThis.Content; await _dbcustom.SaveChangesAsync(); return(NoContent()); }