Esempio n. 1
0
        public async Task <ResultWrapper <UserOutDto> > CreateUser(UserInDto user)
        {
            var errors = userValid.ValidateUserCreation(user);

            if (errors.Count() > 0)
            {
                return(new ResultWrapper <UserOutDto>(null, errors));
            }

            user.Password = ComputeSha256Hash(user.Password);
            var _user = Mapper.Map <Models.DB.User>(user);

            _unitOfWork.UserRepo.AddAsync(_user);
            await _unitOfWork.CompleteAsync();

            return(new ResultWrapper <UserOutDto>(Mapper.Map <UserOutDto>(_user), null));
        }