public void Auth() { User IsAdmin = null; ErrorMes = ""; User IsUser = null; if (Login == null || Password == null || Login == String.Empty || Password == String.Empty) { ErrorMes = "Заполните поля"; } else { using (MyDbContext db = new MyDbContext()) { try { //User tmp = eFUserRepository.getLogin(Login); //tmp = eFUserRepository.getByPs(Password); string Pass = DB.DB.Hash(Password); //User tmp = eFUserRepository.getUser(Login,Pass); IsUser = eFUserRepository.getUser(Login, Pass); IsAdmin = eFUserRepository.getAdmin(Login, Pass); if (IsUser != null || IsAdmin != null) { App.CurrentUser = IsUser; if (IsAdmin != null) { MainAdminWindow sp = new MainAdminWindow(); Close(); Thread myThread = new Thread(new ThreadStart(DB.DB.ShowLoader)); myThread.SetApartmentState(ApartmentState.STA); myThread.Start(); Thread.Sleep(1000); myThread.Abort(); sp.WindowStartupLocation = WindowStartupLocation.CenterScreen; sp.Show(); } else { MainClientWindow sp = new MainClientWindow(); Close(); Thread myThread = new Thread(new ThreadStart(DB.DB.ShowLoader)); myThread.SetApartmentState(ApartmentState.STA); myThread.Start(); Thread.Sleep(1000); myThread.Abort(); sp.WindowStartupLocation = WindowStartupLocation.CenterScreen; sp.Show(); } } else { ErrorMes = "Некорректные данные"; } } catch (Exception ex) { } } } }