public void Delete(int id) { var deletedEntity = _context.Find <TEntity>(id); _context.Remove(deletedEntity); _context.SaveChanges(); }
// GET api/values/5 public HttpResponseMessage Get(int id) { var book = db.Find <Book>(id); if (book == null) { return(Request.CreateResponse(HttpStatusCode.NotFound, new ErrorResponseModel() { ErrorCode = HttpStatusCode.NotFound.ToString(), ErrorMessage = "Book with id wasn't founded." })); } return(Request.CreateResponse(HttpStatusCode.OK, book)); ; }
public void deleteName(int id) { Name name = context.Find <Name>(id); if (name != null) { context.Remove(name); context.SaveChanges(); } }