Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        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();
        }