public void Save(UserLogModel userLogModel)
        {
            var userLogEntity = userLogModel.Map <UserLogEntity>();

            UserLogRepository.Add(userLogEntity);
            DatabaseUnitOfWork.SaveChanges();
        }
        public void Save(long userId, LogType logType)
        {
            var userLog = UserLogFactory.Create(userId, logType);

            DatabaseUnitOfWork.UserLogRepository.Add(userLog);
            DatabaseUnitOfWork.SaveChanges();
        }
예제 #3
0
        public Task <IResult <string> > DeleteAsync(long userId)
        {
            UserRepository.Delete(userId);

            DatabaseUnitOfWork.SaveChanges();

            return(new SuccessResult <string>().ToTask());
        }
예제 #4
0
        public Task <IResult <string> > UpdateAsync(UpdateUserModel updateUserModel)
        {
            var validationResult = new UpdateUserModelValidator().Valid(updateUserModel);

            if (!validationResult.Success)
            {
                return(Task.FromResult(validationResult));
            }

            var userEntity = updateUserModel.Map <UserEntity>();

            var userEntityDatabase = UserRepository.Select(userEntity.UserId);

            userEntity.Login = userEntityDatabase.Login;

            userEntity.Password = userEntityDatabase.Password;

            UserRepository.Update(userEntity, userEntity.UserId);

            DatabaseUnitOfWork.SaveChanges();

            return(new SuccessResult <string>().ToTask());
        }
예제 #5
0
        public Task <IResult <long> > AddAsync(AddUserModel addUserModel)
        {
            var validationResult = new AddUserModelValidator().Valid(addUserModel);

            if (!validationResult.Success)
            {
                return(new ErrorResult <long>(validationResult.Message).ToTask());
            }

            var signInModel = new SignInModel(addUserModel.Login, addUserModel.Password);

            addUserModel.Login = signInModel.LoginHash();

            addUserModel.Password = signInModel.PasswordHash();

            var userEntity = addUserModel.Map <UserEntity>();

            UserRepository.Add(userEntity);

            DatabaseUnitOfWork.SaveChanges();

            return(new SuccessResult <long>(userEntity.UserId).ToTask());
        }