public ActionResult EditSuperAdmin(superadmin s, int id) { if ((string)Session["user"] != null) { superadmin superadmintoupdate = data.superadmin.Where(x => x.id == id).FirstOrDefault(); Debug.WriteLine(superadmintoupdate); Debug.WriteLine(id); Debug.WriteLine(s.superadminid); Debug.WriteLine(s.superadminname); Debug.WriteLine(s.superadminpassword); Debug.WriteLine(s.superadminconfirmpassword); //superadmintoupdate.id = s.id; superadmintoupdate.superadminid = s.superadminid; superadmintoupdate.superadminname = s.superadminname; superadmintoupdate.superadminpassword = Crypto.Hash(s.superadminpassword); superadmintoupdate.superadminconfirmpassword = Crypto.Hash(s.superadminconfirmpassword); try { data.Entry(superadmintoupdate).State = EntityState.Modified; data.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(RedirectToAction("ListSuperAdmin")); } return(RedirectToAction("Login", "User")); }
public ActionResult EditStudentProfile(student s, int id) { if ((string)Session["user"] != null) { student studenttoupdate = data.student.Where(x => x.id == id).FirstOrDefault(); // Debug.WriteLine(studenttoupdate); // Debug.WriteLine(id); // Debug.WriteLine(s.studentid); // Debug.WriteLine(s.studentname); // Debug.WriteLine(s.studentpassword); // Debug.WriteLine(s.studentconfirmpassword); studenttoupdate.studentid = s.studentid; studenttoupdate.studentname = s.studentname; studenttoupdate.studentpassword = Crypto.Hash(s.studentpassword); studenttoupdate.studentconfirmpassword = Crypto.Hash(s.studentconfirmpassword); studenttoupdate.studentdob = s.studentdob; studenttoupdate.studentphone = s.studentphone; studenttoupdate.studentaddress = s.studentaddress; studenttoupdate.studentemail = s.studentemail; studenttoupdate.studentbloodgroup = s.studentbloodgroup; studenttoupdate.studentfees = s.studentfees; studenttoupdate.classid = s.classid; studenttoupdate.sectionid = s.sectionid; try { data.Entry(studenttoupdate).State = EntityState.Modified; data.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } return(RedirectToAction("StudentIndex")); } return(RedirectToAction("Login", "User")); }