public async Task <IActionResult> Login(LoginVM viewModel) { var user = await db.GetEmployeeAsync(viewModel.Id); if (user != null && user.Password == viewModel.Password) { await Authenticate(user); return(RedirectToAction("Index", "Home")); } return(View(viewModel)); }
public async Task <IActionResult> Index() { if (!User.Identity.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } var employee = await dbContext.GetEmployeeAsync(Int32.Parse(User.Identity.Name)); if (employee.IsAdmin()) { return(RedirectToAction("List", "Employes")); } else { return(RedirectToAction("Index", "WorkingPlan", new { employeeId = employee.Id })); } }