public void Remove(TModel entity) { if (_context.Entry(entity).State == EntityState.Detached) { _modelDbSets.Attach(entity); } _modelDbSets.Remove(entity); }
public async Task <IActionResult> PutUserModel(Guid id, UserModel userModel) { if (id != userModel.Id) { return(BadRequest()); } _context.Entry(userModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProduct(Guid id, ProductModel product) { if (id != product.Id) { return(BadRequest()); } _context.Entry(product).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }