public RepositoryController GetInstance() { if (controller == null) { controller = new RepositoryController(); } return(controller); }
public void OnPropertyChanged([CallerMemberName] string prop = "") { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(prop)); IRepController controller = new RepositoryController(); controller.UpdateProductPositionInDB(this); } }
public void Execute() { try { var md5 = MD5.Create(); byte[] hash = md5.ComputeHash(Encoding.UTF8.GetBytes(user_password)); string password = ""; foreach (byte bit in hash) { password += bit; } string expression = "+375([1-9]{2})[0-9]{3}-[0-9]{2}-[0-9]{2}"; if (!Regex.IsMatch(phone, "[+]375[(][1-9]{2}[)][0-9]{3}-[0-9]{2}-[0-9]{2}", RegexOptions.None)) { throw new Exception("Мобильный номер введен в неверной форме"); } LogisticCompany.model.IRepController repository = new LogisticCompany.model.RepositoryController(); Employee employee = repository.GetEmployeeFromDB(sorname, phone); if (employee != null) { if (employee.password.Equals(password)) { if (employee.role.Equals("Администратор") || employee.SecondName.Equals("Admin")) { LogisticCompany.MainWindow.GetInstance().Content = LogisticCompany.view.AdminWindow.GetInstance(employee).Content; } if (employee.role.Equals("Сотрудник") || employee.SecondName.Equals("Employee")) { LogisticCompany.MainWindow.GetInstance().Content = LogisticCompany.view.EmployeeWindow.GetInstance(employee).Content; } } else { MessageBox.Show("Введены неверные данные\t"); } } else { throw new Exception("Пользователь не найден"); } } catch (Exception e) { MessageBox.Show(e.Message); } }