コード例 #1
0
ファイル: UserService.cs プロジェクト: vbre/CS_2015_Winter
        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();
        }
コード例 #2
0
ファイル: UserService.cs プロジェクト: vbre/CS_2015_Winter
 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();
 }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: vbre/CS_2015_Winter
 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();
 }
コード例 #4
0
ファイル: UserService.cs プロジェクト: vbre/CS_2015_Winter
 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;
 }