public async Task <IResult> UpdateAsync(long lessonId, UpdateLessonModel updateLessonModel)
        {
            var validation = new LessonModelValidator().Valid(updateLessonModel);

            if (!validation.Success)
            {
                return(new ErrorDataResult <long>(validation.Message));
            }

            var lessonEntity = await LessonRepository.SelectAsync(lessonId);

            var nullObjectValidation = new NullObjectValidation <LessonEntity>().Valid(lessonEntity);

            if (!nullObjectValidation.Success)
            {
                return(new ErrorResult(nullObjectValidation.Message));
            }

            var lessonDomain = LessonDomainFactory.Create(lessonEntity);

            lessonDomain.Update(updateLessonModel);

            lessonEntity = lessonDomain.Map <LessonEntity>();

            lessonEntity.LessonId = lessonId;

            await LessonRepository.UpdateAsync(lessonEntity, lessonEntity.LessonId);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessResult());
        }
        public async Task <IDataResult <long> > AddAsync(AddLessonModel addLessonModel)
        {
            var validation = new LessonModelValidator().Valid(addLessonModel);

            if (!validation.Success)
            {
                return(new ErrorDataResult <long>(validation.Message));
            }

            var lessonDomain = LessonDomainFactory.Create(addLessonModel);

            lessonDomain.Add();

            var lessonEntity = lessonDomain.Map <LessonEntity>();

            addLessonModel.LessonGroupTypes.ForEach(x => {
                var domain = LessonGroupDomainFactory.Create(x, lessonEntity.LessonId);
                lessonEntity.LessonGroups.Add(domain.Map <LessonGroupEntity>());
            });

            await LessonRepository.AddAsync(lessonEntity);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessDataResult <long>(lessonEntity.LessonId));
        }