public IActionResult Reset() { ForensicRepository repo = new ForensicRepository(Configuration); repo.ResetDb(); HttpContext.SignOutAsync(); return(RedirectToAction("Login")); }
public IActionResult Index(string search = null, string order = null) { HomeViewModel viewModel = new HomeViewModel(); ForensicRepository repo = new ForensicRepository(Configuration); if (String.IsNullOrEmpty(search) && String.IsNullOrEmpty(order)) { viewModel.Flowers = new System.Data.DataTable(); viewModel.Flowers = repo.GetFlowerList(null, "flower_name");; return(View(viewModel)); } var result = repo.GetFlowerList(search, order); viewModel.Flowers = new System.Data.DataTable(); viewModel.Flowers = result; return(View(viewModel)); }
public IActionResult Login(LoginViewModel loginViewModel) { if (ModelState.IsValid) { ForensicRepository repo = new ForensicRepository(Configuration); var result = repo.GetSingleUser(loginViewModel.UserName); if (String.IsNullOrEmpty(result.username)) { ModelState.AddModelError(string.Empty, "Unable to login. The username inserted is not valid."); return(View()); } var claims = new[] { new Claim(ClaimTypes.Name, result.username) }; var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); HttpContext.SignInAsync(new ClaimsPrincipal(identity)); return(RedirectToAction("Index", "Home")); } return(View()); }