public LoginWindow(AuthenticationViewModel viewModel) { viewModel.OnRequestClose += CloseWindow; viewModel.OnRequestFocus += RequestFocus; ViewModel = viewModel; InitializeComponent(); }
public AuthenticationViewModelTests() { Subject = new AuthenticationViewModel() { Settings = Settings }; }
public ActionResult Login(AuthenticationViewModel avm) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Invalid data"); return(View(avm)); } UserEntity user = new UserEntity() { Login = avm.Login, PasswordHash = userService.GetHash(avm.Password) }; if (userService.ValidAuthentication(user.Login, user.PasswordHash)) { SessionPersister.Username = user.Login; LogIn(user.Login); return(Redirect("/Home/Index")); } else { ModelState.AddModelError("", "Wrong login or password"); return(View(avm)); } }
public ActionResult Login(AuthenticationViewModel model, string returnUrl) { PersonMembershipProvider memberShip = new PersonMembershipProvider(); if (ModelState.IsValid) { if (memberShip.ValidateUser(model.Person.Email, model.Person.Password)) { FormsAuthentication.SetAuthCookie(model.Person.Email, false); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "Неправильный пароль или логин"); } } return(View(model)); }
public SignUpPage() { InitializeComponent(); httpClient = new HttpClient(); BindingContext = _authenticationViewModel = new AuthenticationViewModel(); }
async private void LogInButton(object sender, EventArgs e) { var email = EmailInput.Text; var password = PasswordInput.Text; if (string.IsNullOrWhiteSpace(email) || (string.IsNullOrWhiteSpace(password))) { await DisplayAlert("Alert", "Fill all the fields", "OK"); } else { bool answer = await AuthenticationViewModel.checkUser(email, password); if (answer) { await DisplayAlert("Alert", "Authentication failed", "OK"); EmailInput.Text = ""; PasswordInput.Text = ""; } else { //await DisplayAlert("Alert", "passed", "OK"); await Navigation.PushAsync(new TabbedPage1()); } } }
public ActionResult SignIn(string userName, string password) { var signInManager = GetSignInManager(); // Convert to viewmodel. AuthenticationViewModel viewModel = new AuthenticationViewModel() { Password = password, UserName = userName }; if (!TryValidateModel(viewModel)) { return(View("InvalidCredentials")); } var result = signInManager.PasswordSignIn(viewModel.UserName, viewModel.Password, true, false); switch (result) { case SignInStatus.Success: return(Redirect("/")); } return(View("InvalidCredentials")); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var commandLineArgs = System.Environment.GetCommandLineArgs(); if (Settings.Default.Config == null) { Settings.Default.Config = new AppConfig(); } var pathToMdfFileDirectory = Directory.GetCurrentDirectory();// @"d:\temp\"; AppDomain.CurrentDomain.SetData("DataDirectory", pathToMdfFileDirectory); try { //Create a custom principal with an anonymous identity at startup CustomPrincipal customPrincipal = new CustomPrincipal(new AnonymousIdentity()); AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal); base.OnStartup(e); //Show the login view AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService()); LoginWindow loginWindow = new LoginWindow(viewModel); loginWindow.Show(); base.OnStartup(e); } catch (Exception ex) { appLoger.SetLog(ex.Message + ex.StackTrace, System.Diagnostics.EventLogEntryType.Information); System.Windows.Forms.MessageBox.Show(ex.Message); } }
public IActionResult Login(AuthenticationViewModel model) { // Assume the user is not authorized IActionResult result = Unauthorized(); try { var roleMgr = new RoleManager(_db) { //User = _db.GetUserItemByEmail(model.Email) User = _db.GetUserItemByLogin(model.EmailOrUsername) }; // Generate a password hash var pwdMgr = new PasswordManager(model.Password, roleMgr.User.Salt); if (pwdMgr.Verify(roleMgr.User.Hash)) { // Create an authentication token var token = _tokenGenerator.GenerateToken(roleMgr.User.Username, roleMgr.RoleName); // Switch to 200 OK result = Ok(token); } } catch (Exception) { result = BadRequest(new { Message = "Username or password is invalid." }); } return(result); }
public _LayoutViewModel(ClaimsUser claimsUser) { if (claimsUser != null) { AuthenticationViewModel = new AuthenticationViewModel(claimsUser); } }
public ActionResult Registration(Registred model) { if (ModelState.IsValid) { if (model.Password != model.ConfirmPassword) { AuthenticationViewModel Newmodel = new AuthenticationViewModel() { Registred = new Registred(), MasterPage = UpdateMasterPageData() }; return(View("Autification", Newmodel)); } if (!userService.ExistUser(model.Login)) { userService.CreateNewUser(model); if (userService.ExistUser(model.Login)) { FormsAuthentication.SetAuthCookie(model.Login, true); return(RedirectToAction("Index", "Home")); } } } AuthenticationViewModel Newmodels = new AuthenticationViewModel() { Registred = new Registred(), MasterPage = UpdateMasterPageData() }; return(View("Autification", Newmodels)); }
public async Task <IActionResult> Login(AuthenticationViewModel model) { if (ModelState.IsValid) { var result = await signInManager.PasswordSignInAsync( model.Username, model.Password, model.RememberMe, false); if (result.Succeeded) { if (Request.Query.Keys.Contains("ReturnUrl")) { return(Redirect(Request.Query["ReturnUrl"].First())); } else { return(RedirectToAction("Index", "Home")); } } } ModelState.AddModelError(string.Empty, "Incorrect username or password!"); return(View()); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); IUnitOfWork unitOfWork = new UnitOfWork(ConfigurationManager.ConnectionStrings["SqlExpressConnectionString"].ConnectionString); // (localdb)\MSSQLLocalDB connection // IUnitOfWork unitOfWork = new UnitOfWork(ConfigurationManager.ConnectionStrings["MSSqlLocalDbConnectionString"].ConnectionString); AuthenticationService authService = new AuthenticationService(unitOfWork.GetRepository <Core.Models.UserModel>()); LoginWindow loginWindow = new LoginWindow(); AuthenticationViewModel loginViewModel = new AuthenticationViewModel(loginWindow, authService); Current.ShutdownMode = ShutdownMode.OnExplicitShutdown; if (loginWindow.ShowDialog() == true) { Current.ShutdownMode = ShutdownMode.OnMainWindowClose; MainWindow mainView = new MainWindow(); ShellViewModel mainViewModel = new ShellViewModel(mainView, unitOfWork); mainView.InitializeViewModels(); Current.MainWindow = mainView; } else { Current.Shutdown(); } }
public ActionResult Logout(string timeOut) { AuthenticationViewModel authViewModel = new AuthenticationViewModel(); var RoleId = 0; try { Logger.Debug("Authentication Controller Logout"); RoleId = ((SessionInfo)Session["SessionInfo"]).RoleId; LogoutUser(); FormsAuthentication.SignOut(); if (timeOut == "Timeout") { } } catch (Exception ex) { authViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01")); Logger.Error("Authentication Controller - Logout " + ex.Message); } return(RedirectToAction("Index", "Login")); }
public ActionResult AuthenticateUser(AuthenticationViewModel authViewModel) { try { SessionInfo session = _authMan.AuthernticateLogin(authViewModel.Session); if (session.User_Name == authViewModel.Session.User_Name) { SetUsersSession(session); return(RedirectToAction("Index", "Dashboard")); } else { TempData["FriendlyMessage"] = MessageStore.Get("SYS03"); return(RedirectToAction("Index", "Home")); } } catch (Exception ex) { Logger.Error("Authentication : " + ex.Message); HttpContext.Session.Clear(); TempData["FriendlyMessage"] = MessageStore.Get("SYS01"); return(RedirectToAction("Index", "Home")); } }
private void LoginCommandExecute() { PersonViewModel admin; using (var ctx = new IncheckerDbCtx()) { admin = new PersonViewModel(ctx.Persons.First(n => n.Role == Common.Enums.Roles.Admin)); } if (string.IsNullOrEmpty(admin.Pin)) { LoggedPerson = admin; } else { using (var dataCtx = new AuthenticationViewModel(Common.Enums.AuthenticationModes.Admin, admin)) { var auth = new AuthenticationView(); auth.ShowDialogWithViewModel(dataCtx); if (dataCtx.UserAuthenticated == true) { LoggedPerson = admin; } else { LoggedPerson = null; } } } RaisePropertyChanged(nameof(AdvancedFunctionsEnabled)); }
public LoginScreen() { Debug.WriteLine("LoginScreen Initialize"); InitializeComponent(); AuthViewModel = AuthenticationViewModel.GetInstance(); this.DataContext = AuthViewModel; }
public async Task <IActionResult> Update(string scheme) { AuthenticationViewModel model; var definition = await _manager.FindBySchemeAsync(scheme); if (definition == null) { return(NotFound()); } else { model = new AuthenticationViewModel { Scheme = definition.Scheme, DisplayName = definition.DisplayName, HandlerType = definition.HandlerType.Name }; var oAuthOptions = definition.Options as OAuthOptions; // GoogleOptions is OAuthOptions model.ClientId = oAuthOptions.ClientId; model.ClientSecret = oAuthOptions.ClientSecret; } return(View(model)); }
public async Task <IOperationResult <AuthenticationViewModel> > Login(AuthenticationRequest authenticationRequest) { try { IOperationResult <string> validationLoginModelResult = ValidateLoginModel(authenticationRequest); if (!validationLoginModelResult.Success) { return(OperationResult <AuthenticationViewModel> .Fail(validationLoginModelResult.Message)); } string encrypPassword = _encrypService.EncrypText(authenticationRequest.Password); SystemUser user = await _systemUserRepository.FindAsync(user => user.Username == authenticationRequest.Username && user.Password == encrypPassword); IOperationResult <string> validationUserResult = ValidateULogedUser(user); if (!validationUserResult.Success) { return(OperationResult <AuthenticationViewModel> .Fail(validationUserResult.Message)); } AuthenticationViewModel authenticationResponse = _userService.GetToken(user); return(OperationResult <AuthenticationViewModel> .Ok(authenticationResponse)); } catch { return(OperationResult <AuthenticationViewModel> .Fail("Ha ocurrido un error en la autenticación del usuario")); } }
private void CheckInCommandExecute(int id) { using (var ctx = new IncheckerDbCtx()) { var person = ctx.Persons.FirstOrDefault(n => n.Id == id); if (person == null) { return; } if (string.IsNullOrEmpty(person.Pin)) { person.CheckinTime = DateTime.Now; ctx.SaveChanges(); } else { using (var dataCtx = new AuthenticationViewModel(Common.Enums.AuthenticationModes.CheckInOut , new PersonViewModel(person))) { var auth = new AuthenticationView(); auth.ShowDialogWithViewModel(dataCtx); if (dataCtx.UserAuthenticated == true) { person.CheckinTime = DateTime.Now; ctx.SaveChanges(); } } } } RefreshPersonsInOut(); }
public async Task <IHttpActionResult> Authenticate(AuthenticationViewModel authModel) { if (!ModelState.IsValid) { return(BadRequest("Invalid Model State.")); } if (authModel == null) { return(NotFound()); } if (string.IsNullOrWhiteSpace(authModel.Badge) || !int.TryParse(authModel.Badge, out _)) { return(BadRequest("Invalid badge number.")); } if (string.IsNullOrWhiteSpace(authModel.DeviceGuid)) { return(BadRequest("Invalid Device Id.")); } authModel = await Handler.Authenticate(authModel); return(authModel != null ? Ok(authModel) : (IHttpActionResult)Unauthorized()); }
public IActionResult Login(AuthenticationViewModel model) { if (ModelState.IsValid) { User user = authManager.CheckAuthentication(model); if (user != null) { var userInfo = JsonConvert.SerializeObject(user); HttpContext.Session.SetString("userInfo", userInfo); return(RedirectToAction("Index", "Home")); } else { HttpContext.Session.SetString("userInfo", ""); ViewData["Message"] = Alert.AlertGenerate("Falied", "Log in Falied", "Enter Valid Email or Password"); return(View()); } } else { HttpContext.Session.SetString("userInfo", ""); ViewData["Message"] = Alert.AlertGenerate("Falied", "Log in Falied", "Fill up all fields correctly"); return(View()); } }
public async Task <ActionResult <string> > Authentication(AuthenticationViewModel auth) { const string endpointName = nameof(Authentication); string header = $"POST | {auth.Email} | {controllerName}: {endpointName}"; try { logger.LogInformation((int)LogEventEnum.Events.GetItem, $"{header} - {MessageLog.Start.Value}"); string token = await service.Authentication(auth.Email, auth.Senha); if (string.IsNullOrEmpty(token)) { logger.LogWarning((int)LogEventEnum.Events.GetItem, $"{header} - {MessageError.UserPasswordInvalid.Value}"); return(BadRequest(new { message = MessageError.UserPasswordInvalid.Value })); } logger.LogInformation((int)LogEventEnum.Events.GetItem, $"{header} - {MessageLog.Stop.Value} | Token: {token}"); return(Ok(token)); } catch (Exception ex) { logger.LogError((int)LogEventEnum.Events.GetItemError, ex, $"{header} - {MessageLog.Error.Value} | Exception: {ex.Message}"); return(StatusCode(StatusCodes.Status500InternalServerError, new { message = MessageError.InternalError.Value, error = ex.Message })); } }
public MainWindow() { InitializeComponent(); AuthenticationViewModel viewModel = new AuthenticationViewModel(new AuthenticationService()); this.LoginLayer.DataContext = viewModel; }
private void InitialiseAllViewModels() { _SplashScreenViewModel = new SplashScreenViewModel(); _RegistrationViewModel = new RegistrationViewModel(); _ModifyViewModel = new ModifyViewModel(); _AuthenticationViewModel = new AuthenticationViewModel(); }
public ItemDetailAddNewContentDialog(AuthenticationViewModel authVM, ItemDetailViewModel catDVM) { _authVM = authVM; _catDVM = catDVM; Success = false; this.InitializeComponent(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); _authenticationVM = (AuthenticationViewModel)e.Parameter; Initializeitems(); }
public IActionResult Authenticate([FromBody] AuthenticationViewModel userDto) { //yes, the dto is listed as email to support the client library //we will use as username var user = _userService.Authenticate(userDto.email, userDto.password); if (user == null) { return(BadRequest(new { Message = "Username or password is incorrect" })); } var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(_settings.Value.Secret); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, user.Id.ToString()) }), Expires = DateTime.UtcNow.AddDays(7), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor); var tokenString = tokenHandler.WriteToken(token); // return basic user info (without password) and token to store client side return(Ok(new { Id = user.Id, Username = user.Username, FirstName = user.FirstName, LastName = user.LastName, Token = tokenString })); }
public ActionResult Authentication(AuthenticationPostModel postModel) { var model = new AuthenticationViewModel(); if (!ModelState.IsValid) { return(View(model)); } var userName = postModel.Username; var password = _passwordHashProvidcer.Hash(postModel.Password, _salt); var user = _unitOfWork.UserRepository.GetUserByUsernameAndPassword(userName, password); if (user != null) { FormsAuthentication.SetAuthCookie(user.UserName, false); // Not a good practice Session[SessionUserKey] = user; // Map User to Model model = new AuthenticationViewModel() { IdHashed = _encryptionProvider.Encrypt(user.Id.ToString(), _key, _vector), Name = user.Name, EMail = user.EMail.SanitizeEmail() }; } return(View(model)); }
public async Task <IActionResult> Create(AuthenticationViewModel model) { if (ModelState.IsValid) { OAuthOptions oAuthOptions; if (HandlerHelper.GetProviderName(model.HandlerType) == "Google") { oAuthOptions = new GoogleOptions(); } else { oAuthOptions = new OAuthOptions(); } oAuthOptions.ClientId = model.ClientId; oAuthOptions.ClientSecret = model.ClientSecret; oAuthOptions.CallbackPath = "/signin-" + model.Scheme; await _manager.AddAsync(new SchemeDefinition { Scheme = model.Scheme, DisplayName = model.DisplayName, HandlerType = _manager.ManagedHandlerType.First(t => t.Name == model.HandlerType), Options = oAuthOptions }); return(RedirectToAction("List")); } return(View(model)); }
public Design() { Authentication = new AuthenticationViewModel( new DesignAuthenticationService(), new DesignAuthenticator(), new DesignServerAccess(), new DesignNavigationService(), new DesignServerSettings(), new DesignCredentialsStorage(), new AuthenticationRequest() ); Authentication.OnNavigatedTo(); }
public ActionResult Login(AuthenticationViewModel model, string returnUrl) { if (!ModelState.IsValid) { return View(model); } User user = _adminRepo.GetUserByUsername(model.Username); if (user != null) { if (user.AuthentiateUser(user.Username, model.Password)) { FormsAuthentication.SetAuthCookie(user.Username, false); Client userClient = _adminRepo.GetClientById(user.ClientId); // get the auth ticket and set the cookie BasicPrincipal principal = new BasicPrincipal(user, userClient.Name); BasicPrincipalSerializationModel serializationModel = principal.Serialize(); string userData = new JavaScriptSerializer().Serialize(serializationModel); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, user.Username, DateTime.Now, DateTime.Now.AddMinutes(300), false, userData, FormsAuthentication.FormsCookiePath); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket)) { Domain = FormsAuthentication.CookieDomain, HttpOnly = true }; System.Web.HttpContext.Current.Response.Cookies.Set(cookie); if (user.Username == "admin") { return RedirectToAction("Index", "Home", new {area = "Admin"}); } return RedirectToLocal(returnUrl); } } ModelState.AddModelError("", "Invalid login attempt."); return View(model); }
public AuthenticationViewModelTest() { this.authenticationStepFactory = new Mock<IAuthenticationStepFactory>(); this.testee = new AuthenticationViewModel(this.authenticationStepFactory.Object, Mock.Of<IBusyIndicationViewModel>()); }
public AuthenticationView(AuthenticationViewModel viewModel) { ViewModel = viewModel; InitializeComponent(); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); CustomPrincipal customPrincipal = new CustomPrincipal(); AppDomain.CurrentDomain.SetThreadPrincipal(customPrincipal); AuthenticationService authenticationService = new AuthenticationService(App._dataDC); if (e != null && e.Args != null && e.Args.Count<string>() > 0) { try { Dictionary<string, string> dic = this.MakeDictionary(e.Args); if (dic != null) { try { User user = authenticationService.AuthenticateUser(dic["User"], dic["Pass"]); customPrincipal = (Thread.CurrentPrincipal as CustomPrincipal); if (customPrincipal == null) { throw new ArgumentException("The application's default thread principal must be set to a CustomPrincipal object on startup."); } customPrincipal.Identity = new CustomIdentity(user.Username, user.Role); } catch (UnauthorizedAccessException exp) { MessageBox.Show("Login failed! Please provide some valid credentials."); } catch (Exception ex) { MessageBox.Show("ERROR: {0}", ex.Message); } if (this.IsAuthenticated) { MainWindowViewModel viewModel = null; MainWindow window = new MainWindow(); string notamType = null; try { if (dic.ContainsKey("GetAddr")) { var aftnService = new AftnService(App._dataDC2); var AftnList = aftnService.GetAftnList().OrderBy(t => t.Series).ToList(); string strFinal=""; foreach(var aftn in AftnList) { strFinal += aftn.Series + "=" + aftn.AftnList+"\n"; } System.IO.File.WriteAllText("C:\\NOTDIR\\ADDR.TXT", strFinal); Application.Current.Shutdown(); return; } if (dic["NotamType"] != null) { notamType = dic["NotamType"].Substring(dic["NotamType"].Length - 1); } if (dic["NotamType"].Contains("NOTAM")) { if (dic["Originat"].IndexOf("OI") != 0) { IntlNotam notam = new IntlNotam { Number = dic.ContainsKey("Num") ? dic["Num"] : "", NotamType = notamType, SendTime = dic.ContainsKey("Filling") ? dic["Filling"] : "", Type = dic.ContainsKey("Type") ? dic["Type"] : "", Year = dic.ContainsKey("year") ? dic["year"] : "", RefType = dic.ContainsKey("RefT") ? dic["RefT"] : "", RefYear = dic.ContainsKey("RefY") ? dic["RefY"] : "", RefNum = dic.ContainsKey("RefN") ? dic["RefN"] : "", LowerLimit = dic.ContainsKey("Lower") ? dic["Lower"] : "", HigherLimit = dic.ContainsKey("Upper") ? dic["Upper"] : "", Latitude = dic.ContainsKey("Latitude") ? dic["Latitude"] : "", Longtitude = dic.ContainsKey("Longtitude") ? dic["Longtitude"] : "", Radius = dic.ContainsKey("Radius") ? dic["Radius"] : "", FirAero = dic.ContainsKey("FirAd") ? dic["FirAd"] : "", FromDate = dic.ContainsKey("FromDate") ? dic["FromDate"] : "", ToDate = dic.ContainsKey("ToDate") ? dic["ToDate"] : "", PermEst = dic.ContainsKey("EstPerm") ? dic["EstPerm"] : "", EFreeText = dic.ContainsKey("ItemE") ? dic["ItemE"] : "", DFreeText = dic.ContainsKey("ItemD") ? dic["ItemD"] : "", FFreeText = dic.ContainsKey("ItemF") ? dic["ItemF"] : "", GFreeText = dic.ContainsKey("ItemG") ? dic["ItemG"] : "", Origin = dic.ContainsKey("FIR") ? ( from o in App._dataDC2.Origins where o.Code.Equals(dic["Originat"]) select o).FirstOrDefault<Origin>() : null, FIR = dic.ContainsKey("FIR") ? App._dataDC2.FIRs.Where(n => (n.Code.Length==4) && n.Code.Substring(0,2).Equals(dic["FIR"].Substring(0,2))).FirstOrDefault() : null, Status = "D", NotamCode = dic.ContainsKey("QCode") ? ( from o in App._dataDC2.NotamCodes where (o.Subject + o.Condition).Equals(dic["QCode"]) select o).FirstOrDefault<NotamCode>() : null }; IntlNotamService intlNotamService = new IntlNotamService(App._dataDC2); if (!intlNotamService.ContainsNotam(notam)) { intlNotamService.Insert(notam); // MessageBox.Show("International NOTAM Inserted To Database Successfully"); } else { // MessageBox.Show("International NOTAM Already Inserted To Database"); } Application.Current.Shutdown(); return; } // if (!dic.ContainsKey("FIR")) // { // dic.Add("FIR", "OIIX"); // } // Notam notam2 = new Notam // { // Number = "", // NotamType = notamType, // SendTime = dic.ContainsKey("Filling") ? dic["Filling"] : "", // Type = dic.ContainsKey("Type") ? dic["Type"] : "", // Year = dic.ContainsKey("year") ? dic["year"] : "", // RefType = dic.ContainsKey("RefT") ? dic["RefT"] : "", // RefYear = dic.ContainsKey("RefY") ? dic["RefY"] : "", // RefNum = dic.ContainsKey("RefN") ? dic["RefN"] : "", // LowerLimit = dic.ContainsKey("Lower") ? dic["Lower"] : "", // HigherLimit = dic.ContainsKey("Upper") ? dic["Upper"] : "", // Latitude = dic.ContainsKey("Latitude") ? dic["Latitude"] : "", // Longtitude = dic.ContainsKey("Longtitude") ? dic["Longtitude"] : "", // Radius = dic.ContainsKey("Radius") ? dic["Radius"] : "", // FirAero = dic.ContainsKey("FirAd") ? dic["FirAd"] : "", // FromDate = dic.ContainsKey("FromDate") ? dic["FromDate"] : "", // ToDate = dic.ContainsKey("ToDate") ? dic["ToDate"] : "", // PermEst = dic.ContainsKey("EstPerm") ? dic["EstPerm"] : "", // EFreeText = dic.ContainsKey("ItemE") ? dic["ItemE"] : "", // DFreeText = dic.ContainsKey("ItemD") ? dic["ItemD"] : "", // FFreeText = dic.ContainsKey("ItemF") ? dic["ItemF"] : "", // GFreeText = dic.ContainsKey("ItemG") ? dic["ItemG"] : "", // Origin = ( // from o in App._dataDC2.Origins // where o.Code.Equals(dic["Originat"]) // select o).FirstOrDefault<Origin>(), // FIR = ( // from o in App._dataDC2.FIRs // where o.Code.Equals(dic["FIR"]) // select o).FirstOrDefault<FIR>(), // Status = "D", // NotamCode = dic.ContainsKey("QCode") ? ( // from o in App._dataDC2.NotamCodes // where (o.Subject + o.Condition).Equals(dic["QCode"]) // select o).FirstOrDefault<NotamCode>() : null // }; // viewModel = new MainWindowViewModel(App._dataDC2, notam2); } else { if (dic["NotamType"].Contains("RQN")) { SendRQN(dic, App._dataDC2); } else { SendRQL(dic); } Application.Current.Shutdown(); return; } } catch (System.Exception ex) { MessageBox.Show(ex.Message); Application.Current.Shutdown(); return; } EventHandler handler = null; handler = delegate { viewModel.RequestClose -= handler; window.Close(); }; viewModel.RequestClose += handler; window.DataContext = viewModel; window.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (!IsAuthenticated) { //Show the login view AuthenticationViewModel viewModel = new AuthenticationViewModel(authenticationService);