/// <summary> /// User login page. Validates user. /// </summary> /// <param name="email">The email given by the user</param> /// <param name="password">The password given by the user</param> /// <returns>Returns to Main/home page if user is valid, else returns login view with error message</returns> public async Task <ActionResult> UserLogin(string email, string password) { LoginCaller lc = new LoginCaller(); var customer = await lc.GetByLogin(email, password); if (customer != null) { Session["UserId"] = customer.Id.ToString(); Session["LastName"] = customer.LastName; Session["FirstName"] = customer.FirstName; PractitionerCaller pc = new PractitionerCaller(); Practitioner p = await pc.GetPractitionerByURL(customer.Practitioner); Session["PractitionerId"] = p.Id.ToString(); Session["PractitionerFirstName"] = p.FirstName; Session["PractitionerLastName"] = p.LastName; Session["PractitionerPhoneNo"] = p.PhoneNo; } else { TempData["ErrorMessage"] = "Brugeren findes ikke, brugernavn eller password passer ikke"; return(View("Index")); } TempData["SuccessMessage"] = "Du er nu logget ind, velkommen til " + customer.FirstName + "!"; return(RedirectToAction("Index", "Home")); }
public ActionResult Supervisor(SupervisorLogIn model) { var response = new ResponseDTO <LoginResponseDTO>(); var caller = new LoginCaller(); bool redirect = false; try { if (ModelState.IsValid) { response = caller.GetLogin(new UserDTO() { UserName = model.sUser, Password = model.sPassword }); model.Message = (response.Success) ? string.Empty : response.Message; redirect = (response.Success && response.Result.IsAuthenticated) ? true : false; } } catch (System.Exception exception) { //Falta implementar el log ********** model.Message = Key.GetError(); } if (redirect) { SessionVar.SetLoginUser(response.Result); return(RedirectToAction("Administrator", "Menu")); } return(View(model)); }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(txtEmail.Text) && !String.IsNullOrEmpty(txtPassword.Password)) { ClinicCaller clinicCaller = new ClinicCaller(); LoginCaller loginCaller = new LoginCaller(); var practitioner = loginCaller.GetByLogin(txtEmail.Text, txtPassword.Password); if (practitioner != null) { GlobalLoginInfo.UserId = practitioner.Id; GlobalLoginInfo.FullName = practitioner.FirstName + " " + practitioner.LastName; GlobalLoginInfo.Clinic = clinicCaller.GetById(practitioner.Clinic); GlobalLoginInfo.ClinicId = GlobalLoginInfo.Clinic.Id; MainWindow main = new MainWindow(); main.Show(); this.Close(); } } }
void InitializeTest() { loginCaller = new LoginCaller(); response = new ResponseDTO <LoginResponseDTO>(); }