public async Task UpdateAsync <TId>(TId id, T entity) where TId : IComparable { using (var context = new SchoolDB()) { UpdateGraph(context, entity); await context.SaveChangesAsync(); } }
public async Task <T> CreateAsync(T entity) { using (var context = new SchoolDB()) { entity = DbSet(context).Add(entity); await context.SaveChangesAsync(); return(entity); } }
public async Task DeleteAsync <TId>(TId id) where TId : IComparable { using (var context = new SchoolDB()) { Guid userId = Guid.Parse(id.ToString()); var entity = DbSet(context).SingleOrDefault(x => CompareId(id, x)); if (entity != null) { DbSet(context).Remove(entity); await context.SaveChangesAsync(); } } }