public async Task <LessonDetailViewModel> EditLessonAsync(LessonEditInputModel inputModel) { Lesson lesson = await dbContext.Lessons.FindAsync(inputModel.Id); if (lesson == null) { throw new LessonNotFoundException(inputModel.Id); } lesson.ChangeTitle(inputModel.Title); lesson.ChangeDescription(inputModel.Description); lesson.ChangeDuration(inputModel.Duration); lesson.ChangeOrder(inputModel.Order); dbContext.Entry(lesson).Property(lesson => lesson.RowVersion).OriginalValue = inputModel.RowVersion; try { await dbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw new OptimisticConcurrencyException(); } return(LessonDetailViewModel.FromEntity(lesson)); }