public ActionResult Rejestracja(Pacjent model) { using (PrzychodniaContext db = new PrzychodniaContext()) { if (db.Pacjent.Any(x => x.Email == model.Email)) { ViewBag.DuplicateMessage = "Taki email jest zarejestrowany"; return(View("Rejestracja", model)); } else { db.Pacjent.Add(model); db.SaveChanges(); var pacjentDetal = db.Pacjent.Where(x => x.Email == model.Email && x.Haslo == model.Haslo).FirstOrDefault(); if (pacjentDetal == null) { ViewBag.DuplicateMessage = "Zły email lub hasło"; return(View("Logowanie", model)); } else { Session["PacjentId"] = pacjentDetal.PacjentId; Session["Name"] = pacjentDetal.Imie + " " + pacjentDetal.Nazwisko; } } } ModelState.Clear(); return(RedirectToAction("Index", "Wizyta")); }
public ActionResult Logowanie(Pracownik model) { using (PrzychodniaContext db = new PrzychodniaContext()) { var pracownikDetal = db.Pracownik.FirstOrDefault(x => x.Login == model.Login && x.Haslo == model.Haslo); if (pracownikDetal == null) { ViewBag.DuplicateMessage = "Zły email lub hasło"; return(View("Logowanie", model)); } else { Session["PracownikId"] = pracownikDetal.PracownikId; Session["Name"] = pracownikDetal.Imie + " " + pracownikDetal.Nazwisko; return(RedirectToAction("Index", "Admin")); } } }
public ActionResult Logowanie(Pacjent model) { using (PrzychodniaContext db = new PrzychodniaContext()) { var pacjentDetal = db.Pacjent.FirstOrDefault(x => x.Email == model.Email && x.Haslo == model.Haslo); if (pacjentDetal == null) { ViewBag.DuplicateMessage = "Zły email lub hasło"; return(View("Logowanie", model)); } else { Session["PacjentId"] = pacjentDetal.PacjentId; Session["Name"] = pacjentDetal.Imie + " " + pacjentDetal.Nazwisko; return(RedirectToAction("Index", "Wizyta")); } } }