public async Task DeleteLessonAsync(LessonDeleteInputModel inputModel) { int affectedRows = await db.CommandAsync($"DELETE FROM Lessons WHERE Id={inputModel.Id}"); if (affectedRows == 0) { throw new LessonNotFoundException(inputModel.Id); } }
public async Task DeleteLessonAsync(LessonDeleteInputModel inputModel) { Lesson lesson = await dbContext.Lessons.FindAsync(inputModel.Id); if (lesson == null) { throw new LessonNotFoundException(inputModel.Id); } dbContext.Remove(lesson); await dbContext.SaveChangesAsync(); }