Exemple #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();
        }
Exemple #2
0
 public void EditUser(UserDTO user)
 {
     User u = db.Users.GetById(user.Id);
     u.Login = user.Login;
     u.Password = user.Password;
     u.EMail = user.EMail;
     u.IsEMailValid = user.IsEMailValidated;
     u.Character.Name = user.CharacterName;
     db.Users.Update(u);
     db.Save();
 }
Exemple #3
0
 void AddUserClick(object sender, EventArgs e)
 {
     if (!CheckAddUserTextboxesForMinimumValidData())
         return;
     UserDTO user = new UserDTO
     {
         Login = userLogin.Text,
         Password = userPassword.Text,
         EMail = userEmail.Text,
         IsEMailValidated = isEmailValid.Checked,
         CharacterName = playerName.Text,
         RegistrationDate = DateTime.Now
     };
     new UserService(Server).AddUser(user);
     ClearUserEditForm();
 }
Exemple #4
0
 public UserDTO GetUser(int userId)
 {
     User u = db.Users.GetById(userId);
     UserDTO user = new UserDTO
     {
         Id = u.Id,
         Login = u.Login,
         Password = u.Password,
         EMail = u.EMail,
         IsEMailValidated = u.IsEMailValid,
         CharacterName = u.Character.Name,
         RegistrationDate = u.Date
     };
     return user;
 }