Beispiel #1
0
        public static void CreateUser(Abstract.model.User user)
        {
            user.UserId = 1;
            var users = GetCurrencyExchangerContext().User.ToArray();

            foreach (var u in users)
            {
                if (u.UserId == user.UserId)
                {
                    user.UserId = u.UserId + 1;
                }
            }

            GetCurrencyExchangerContext().User.Add(user);
            GetCurrencyExchangerContext().SaveChanges();
        }
Beispiel #2
0
        public override void DoUpdate(int userId, Dictionary <string, object> parameters)
        {
            var user = new Abstract.model.User {
                UserId = userId
            };

            foreach (var row in parameters)
            {
                if (row.Key.Equals("FirstName"))
                {
                    user.FirstName = row.Value.ToString();
                }

                if (row.Key.Equals("LastName"))
                {
                    user.LastName = row.Value.ToString();
                }

                if (row.Key.Equals("Login"))
                {
                    user.Login = row.Value.ToString();
                }

                if (row.Key.Equals("Password"))
                {
                    user.Password = row.Value.ToString();
                }

                if (row.Key.Equals("Address"))
                {
                    user.Address = row.Value.ToString();
                }

                if (row.Key.Equals("City"))
                {
                    user.City = row.Value.ToString();
                }

                if (row.Key.Equals("ZipCode"))
                {
                    user.ZipCode = row.Value.ToString();
                }

                if (row.Key.Equals("BirthDate"))
                {
                    user.BirthDate = (DateTime?)row.Value;
                }

                if (row.Key.Equals("State"))
                {
                    user.State = row.Value.ToString();
                }

                if (row.Key.Equals("Gender"))
                {
                    user.Gender = row.Value.ToString();
                }

                if (row.Key.Equals("Email"))
                {
                    user.EMail = row.Value.ToString();
                }
            }

            GetCurrencyExchangerContext().User.Update(user);
            GetCurrencyExchangerContext().SaveChanges();
        }
Beispiel #3
0
 public static void UpdateUser(Abstract.model.User user)
 {
     GetCurrencyExchangerContext().User.Update(user);
     GetCurrencyExchangerContext().SaveChanges();
 }
Beispiel #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (TextFirstName.Text != "" && TextLastName.Text != "" && LoginBox.Text != "" &&
                PasswordBox.Password != "" && PasswordBox.Password.Equals(RepeatPasswordBox.Password))
            {
                var newUser = new Abstract.model.User
                {
                    Login    = LoginBox.Text, Password = PasswordBox.Password, FirstName = TextFirstName.Text,
                    LastName = TextLastName.Text, City = TextCity.Text, BirthDate = DateBirth.SelectedDate,
                    State    = ComboState.Text, Address = TextAddress.Text, ZipCode = TextZipCode.Text,
                    EMail    = Email.Text
                };

                if (RadioMale.IsChecked != null && RadioMale.IsChecked.Value)
                {
                    newUser.Gender = "Male";
                }
                else if (RadioFemale.IsChecked != null && RadioFemale.IsChecked.Value)
                {
                    newUser.Gender = "Female";
                }
                AddEmployeeBO.CreateUser(newUser);
                _employeeList.ReloadUsers();
                Close();
            }
            else
            {
                if (TextFirstName.Text == "" || TextLastName.Text == "" || LoginBox.Text == "" ||
                    PasswordBox.Password == "" || RepeatPasswordBox.Password == "")
                {
                    FirstNameMessage.Visibility = TextFirstName.Text == "" ? Visibility.Visible : Visibility.Hidden;

                    LastNameMessage.Visibility = TextLastName.Text == "" ? Visibility.Visible : Visibility.Hidden;

                    LoginMessage.Visibility = LoginBox.Text == "" ? Visibility.Visible : Visibility.Hidden;

                    PasswordMessage.Visibility = PasswordBox.Password == "" ? Visibility.Visible : Visibility.Hidden;
                    if (RepeatPasswordBox.Password == "")
                    {
                        PasswordsDontMatch.Text       = "*";
                        PasswordsDontMatch.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        PasswordsDontMatch.Visibility = Visibility.Hidden;
                    }

                    ShowMessage("Required fields should be filled", "Error", MessageBoxButton.OK);
                }

                else if (!PasswordBox.Password.Equals(RepeatPasswordBox.Password))
                {
                    PasswordsDontMatch.Text       = "*Passwords should match";
                    PasswordsDontMatch.Visibility = Visibility.Visible;
                    ShowMessage("Passwords should match", "Error", MessageBoxButton.OK);
                }
                else
                {
                    PasswordsDontMatch.Visibility = Visibility.Hidden;
                }
            }
        }