public async Task HandleAsync(DeleteCommand <T> command) { var entity = await this.repository.Set <T>().SingleOrDefaultAsync(e => e.Id == command.Id); if (entity != null) { this.repository.Set <T>().Remove(entity); await this.repository.SaveChangesAsync(); } }
public void Handle(DeleteCommand <T> command) { var entity = this.repository.Set <T>().SingleOrDefault(e => e.Id == command.Id); if (entity != null) { this.repository.Set <T>().Remove(entity); this.repository.SaveChanges(); } }