public void Edit(User user)
        {
            using (var contextScope = ContextScopeFactory.Create())
            {
                //var domainUser = _userRepository.GetById(user.UserId);

                //Mapper.Map(user, domainUser);

                _userRepository.Save(_mapper.Map <Faw.Models.Domain.User>(user));

                contextScope.SaveChanges();
            }
        }
        public Guid Register(User user)
        {
            var domainUser = Mapper.Map <Faw.Models.Domain.User>(user);
            var sh         = new SaltedHash(user.Account.Password);
            var now        = DateTime.UtcNow;

            domainUser.Account.PasswordHash = sh.Hash;
            domainUser.Account.PasswordSalt = sh.Salt;

            domainUser.Account.CreatedOn = now;
            domainUser.Account.UpdatedOn = now;

            domainUser.Account.Token           = Guid.NewGuid();
            domainUser.Account.TokenExpireDate = now.AddHours(1);

            domainUser.Account.Status = AccountStatus.PendingActivation;

            var userType = _userTypeQueryService.GetByName(user.Account.UserType);

            if (userType == null)
            {
                throw new ArgumentNullException(nameof(userType));
            }

            domainUser.UserTypeId = userType.UserTypeId;
            domainUser.AccountId  = domainUser.Account.EntityId;

            domainUser.PlayerInfo = new PlayerInfo
            {
                ExpirienceAmount = 0,
                Level            = 1
            };

            domainUser.PlayerInfoId = domainUser.PlayerInfo.EntityId;

            using (var contextScope = ContextScopeFactory.Create())
            {
                _userRepository.Save(domainUser);
                _accountRepository.Save(domainUser.Account);
                _playerInfoRepository.Save(domainUser.PlayerInfo);

                contextScope.SaveChanges();
            }

            return(domainUser.Account.Token.Value);
        }