public ActionResult ChangePassword(ChangePasswordModel changePassword) { if (ModelState.IsValid) { DziennikEntities db = new DziennikEntities(); int personID = (int)Session["personID"]; var person = db.Osoby.Find(personID); if (person.haslo == changePassword.oldPassword) { person.haslo = changePassword.newPassword; person.data_hasla = DateTime.Now; db.SaveChanges(); Logout(); return(RedirectToAction("Login", "Login")); } else { ModelState.AddModelError("oldPassword", "Podane stare hasło jest nieprawidłowe"); } } return(View()); }
public ActionResult EditPersonalDetails(int id, Osoba osoba) { if (ModelState.IsValid) { var person = db.Osoby.AsNoTracking().Where(o => o.id_osoby == id).FirstOrDefault(); osoba.data_urodzenia = person.data_urodzenia; osoba.data_hasla = person.data_hasla; osoba.uprawnienia = person.uprawnienia; osoba.email = person.email; db.Entry(osoba).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("PersonalDetails/" + id)); } return(View()); }
public ActionResult CreateClass(FormCollection formCollection) { Klasa klasa = new Klasa(); klasa.nazwa = formCollection["nazwa"]; klasa.id_wychowawcy = Int32.Parse(formCollection["tutorId"]); db.Klasy.Add(klasa); db.SaveChanges(); return(RedirectToAction("Classes")); }