/// <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")); }
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(); } } }