Example #1
0
        public void AddUser(UserDTO user)
        {
            int newUserId = db.Users.GetLastUsedUserId() + 1;
            Random rnd = new Random();
            User u = new User
            {
                Id = newUserId,
                Login = user.Login,
                Password = user.Password,
                EMail = user.EMail,
                IsEMailValid = user.IsEMailValidated,
                Date = user.RegistrationDate,
                UserTransactions = new List<UserTransaction>() { },
                Character = new Player
                {
                    UserId = newUserId,
                    Name = user.CharacterName,
                    PlayerId = newUserId,
                    Date = DateTime.Now,
                    Statistics = new PlayerStatistic
                    {
                        Wins = rnd.Next(20),
                        Loses = rnd.Next(20),
                        Draws = rnd.Next(20)
                    }
                }

            };
            db.Users.Create(u);
            db.Save();
        }
Example #2
0
        public void Create(UserDto user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(UserDto));
            }
            var userEntity = new DataLayer.Entities.User().InjectFrom(user) as DataLayer.Entities.User;

            userEntity.Password = HashPassword(user.Password);
            repository.Add(userEntity);
            unit.Commit();
        }