예제 #1
0
        public async Task EditUser(SetUserDto setUserDto)
        {
            byte[] bytesPhotoProfile = Convert.FromBase64String(setUserDto.PhotoProfile);

            User user = await _getUserBusiness.GetUserByUserId(setUserDto.Id);

            if (setUserDto.Password != user.Password)
            {
                byte[] bytes;
                new RNGCryptoServiceProvider().GetBytes(bytes = new byte[16]);
                var    derivedBytes = new Rfc2898DeriveBytes(setUserDto.Password, bytes, 10000);
                byte[] hash         = derivedBytes.GetBytes(20);
                byte[] hashBytes    = new byte[36];
                Array.Copy(bytes, 0, hashBytes, 0, 16);
                Array.Copy(hash, 0, hashBytes, 16, 20);
                user.Password = Convert.ToBase64String(hashBytes);
            }
            else
            {
                user.Password = setUserDto.Password;
            }
            user.BackgroundApp = setUserDto.BackgroundApp;
            user.Name          = setUserDto.Name;
            user.LastName      = setUserDto.LastName;
            user.Email         = setUserDto.Email;
            user.DateBirthday  = setUserDto.DateBirthday;
            user.PhotoProfile  = bytesPhotoProfile;
            user.Private       = setUserDto.Private;
            user.Description   = setUserDto.Description;

            _userRepository.EditUser(user);
        }
        public async Task DeleteUserByUserId(int userId)
        {
            var user = await _getUserBusiness.GetUserByUserId(userId);

            _userRepository.DeleteUser(user);
        }