public void Logout() { var rmManager = new RememberMeManager(); rmManager.RemoveUser(); Environment.Exit(0); }
public async Task Login() { using (var context = new Context()) { View.ErrorMessage = string.Empty; var result = await context.Users .FirstOrDefaultAsync(u => u.Login == View.Login && u.Password == View.Password); if (result == null) { View.ErrorMessage = "Неверный пароль или логин!"; View.Password = ""; } else { var rmManager = new RememberMeManager(); if (View.RememberMe) { rmManager.RememberMe(result); } else { rmManager.RemoveUser(); } ShowMainForm(result); } } }
public async Task AutoLogin() { var rmManager = new RememberMeManager(); var user = rmManager.GetUser(); if (user != null) { using (var context = new Context()) { var result = await context.Users .FirstOrDefaultAsync(u => u.Login == user.Login && u.Password == user.Password); if (result != null) { ShowMainForm(result); } } } }