public virtual void Delete(TEntity entityToDelete) { if (context.Entry(entityToDelete).State == EntityState.Detached) { dbSet.Attach(entityToDelete); } dbSet.Remove(entityToDelete); }
public async Task <IActionResult> PutEntry(int id, Entry entry) { if (id != entry.Id) { return(BadRequest()); } _context.Entry(entry).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EntryExists(id)) { return(NotFound()); } else { throw; } } catch (DbUpdateException e) { return(ValidationProblem(new ValidationProblemDetails(new Dictionary <string, string[]>() { { "Link", new string[] { "Model with this Shortcut already exists" } } }))); } return(NoContent()); }