예제 #1
0
        public int AddNewUserOnDB(RegistrateCurrentUser registrate)
        {
            using (var db = new FilmFinderDb())
            {
                if (db.Users.Any(i => i.Name == registrate.Login))
                {
                    return((int)UResult.UserFailed);
                }
                bool tmpGender = true;
                switch (registrate.Gender)
                {
                case 0:
                    tmpGender = false;
                    break;

                case 1:
                    tmpGender = true;
                    break;
                }
                GetHeshMd5 getHesh = new GetHeshMd5();

                db.Users.Add(new User()
                {
                    DateBirthday = registrate.DateBirthday, Name = registrate.Login, Password = getHesh.GetHesh(registrate.Password), Gender = tmpGender, UserImage = File.ReadAllBytes("./usericon.png")
                });
                db.SaveChanges();
            }
            return((int)UResult.Access);
        }
예제 #2
0
        public void ChangeUserProfile(RegistrateCurrentUser user)
        {
            using (var db = new FilmFinderDb())
            {
                var usr = db.Users.First(i => i.Name == _currentUser.Login);
                if (user.Password != null)
                {
                    usr.Password = new GetHeshMd5().GetHesh(user.Password);
                }
                bool tmpGender = true;
                switch (user.Gender)
                {
                case 0:
                    tmpGender = false;
                    break;

                case 1:
                    tmpGender = true;
                    break;
                }

                usr.Gender       = tmpGender;
                usr.DateBirthday = usr.DateBirthday;
                db.SaveChanges();
            }
        }
예제 #3
0
        public void ChangeUser()
        {
            RegistrateCurrentUser usr = new RegistrateCurrentUser();

            if (Password != "")
            {
                if (Password == "" || SecondPassword == "")
                {
                    ErrorMessage = "*Пароли не совпадают";
                    return;
                }
                else if (Password != SecondPassword)
                {
                    ErrorMessage = "*Пароли не совпадают";
                    return;
                }
                else
                {
                    usr.Password = Password;
                }
            }

            usr.Gender       = Gender;
            usr.DateBirthday = DateBirthday.ToString();
            _settings.ChangeUserProfile(usr);
        }
예제 #4
0
        public void RegistrateOnApp(object param)
        {
            RegistrateCurrentUser user = new RegistrateCurrentUser();

            if (Name == "" || Password == "" || PasswordSecond == "")
            {
                ErrorMessage = "*Все поля должны быть заполнены";
                return;
            }
            else if (DateBirthday > DateTime.Now)
            {
                ErrorMessage = "*Возраст не может быть больше текущей даты";
                return;
            }
            else if (Password != PasswordSecond)
            {
                ErrorMessage = "*Пароли не совпадают";
                return;
            }


            byte[] tmp = { };

            user.Login     = Name;
            user.Password  = Password;
            user.Gender    = Gender;
            user.UserImage = tmp;

            user.DateBirthday = DateBirthday.ToString();
            UResult result = (UResult)_loginRegister.AddNewUserOnDB(user);

            if (result == UResult.Access)
            {
                OpenLogin.Execute(null);
            }
            else if (result == UResult.UserFailed)
            {
                ErrorMessage = "*Такой пользователь уже существует";
            }
        }
예제 #5
0
 public void ChangeUserProfile(RegistrateCurrentUser user)
 {
     _server.ChangeUserProfile(user);
 }
예제 #6
0
 public int AddNewUserOnDB(RegistrateCurrentUser registrate)
 {
     return(_server.AddNewUserOnDB(registrate));
 }