예제 #1
0
        private async Task <IResult> Update(UpdateDepartmentLessonModel updateDepartmentLessonModel, Expression <Func <DepartmentLessonEntity, bool> > where)
        {
            var validation = new UpdateDepartmentLessonModelValidator().Valid(updateDepartmentLessonModel);

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

            var DepartmentLessonEntity = await DepartmentLessonRepository.SingleOrDefaultAsync(where);

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

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

            var DepartmentLessonDomain = DepartmentLessonDomainFactory.Create(DepartmentLessonEntity);

            DepartmentLessonDomain.Update(updateDepartmentLessonModel);
            DepartmentLessonEntity = DepartmentLessonDomain.Map <DepartmentLessonEntity>();
            await DepartmentLessonRepository.UpdateAsync(DepartmentLessonEntity, DepartmentLessonEntity.DepartmentLessonId);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessResult());
        }
        public async Task <IResult> UpdateAsync(long constraintId, UpdateConstraintModel updateConstraintModel)
        {
            var validation = new UpdateConstraintModelValidator().Valid(updateConstraintModel);

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

            var constraintEntity = await ConstraintRepository.SelectAsync(constraintId);

            var nullObjectValidation = new NullObjectValidation <ConstraintEntity>().Valid(constraintEntity);

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

            var constraintDomain = ConstraintDomainFactory.Create(constraintEntity);

            constraintDomain.Update(updateConstraintModel);

            constraintEntity = constraintDomain.Map <ConstraintEntity>();

            await ConstraintRepository.UpdateAsync(constraintEntity, constraintEntity.ConstraintId);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessResult());
        }
        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 <IResult> UpdateAsync(long userId, UpdateUserModel updateUserModel)
        {
            var validation = new UpdateUserModelValidator().Valid(updateUserModel);

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

            var userEntity = await UserRepository.SelectAsync(userId);

            var nullObjectValidation = new NullObjectValidation <UserEntity>().Valid(userEntity);

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

            var userDomain = UserDomainFactory.Create(userEntity);

            userDomain.Update(updateUserModel);
            userEntity        = userDomain.Map <UserEntity>();
            userEntity.UserId = userId;
            await UserRepository.UpdateAsync(userEntity, userEntity.UserId);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessResult());
        }
예제 #5
0
        public async Task <IResult> UpdateAsync(long departmentId, UpdateDepartmentModel updateDepartmentModel)
        {
            var validation = new DepartmentModelValidator().Valid(updateDepartmentModel);

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

            var DepartmentEntity = await DepartmentRepository.SelectAsync(departmentId);

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

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

            var DepartmentDomain = DepartmentDomainFactory.Create(DepartmentEntity);

            DepartmentDomain.Update(updateDepartmentModel);
            DepartmentEntity = DepartmentDomain.Map <DepartmentEntity>();
            DepartmentEntity.DepartmentId = departmentId;
            await DepartmentRepository.UpdateAsync(DepartmentEntity, DepartmentEntity.DepartmentId);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessResult());
        }
        public async Task <IResult> UpdateAsync(long facultyId, UpdateFacultyModel updateFacultyModel)
        {
            var validation = new FacultyModelValidator().Valid(updateFacultyModel);

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

            var facultyEntity = await FacultyRepository.SelectAsync(facultyId);

            var nullObjectValidation = new NullObjectValidation <FacultyEntity>().Valid(facultyEntity);

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

            var facultyDomain = FacultyDomainFactory.Create(facultyEntity);

            facultyDomain.Update(updateFacultyModel);

            facultyEntity = facultyDomain.Map <FacultyEntity>();

            facultyEntity.FacultyId = facultyId;

            await FacultyRepository.UpdateAsync(facultyEntity, facultyEntity.FacultyId);

            await DatabaseUnitOfWork.SaveChangesAsync();

            return(new SuccessResult());
        }