public async Task DeleteAsync(int id) { var entity = Apis.Find(id); if (Context.Entry(entity).State == EntityState.Detached) { Apis.Attach(entity); } Apis.Remove(entity); await Context.SaveChangesAsync(); }
public async Task <ApiResourceDTO> UpdateAsync(ApiResourceDTO dto) { var entity = dto.ToEntity(); Apis.Attach(entity); await CleanupApiResourceAsync(entity); Apis.Update(entity); await Context.SaveChangesAsync(); return(entity.ToDTO()); }