public ActionResult SSignUp([Bind(Include = "ID,UserID,Name,ConfirmPassword,Password,Section")] SSignUp signUp) { { try { SSignUp user = db.SSignUps.FirstOrDefault(u => u.UserID == (signUp.UserID)); if (user != null) { ModelState.AddModelError("UserID", "This User is already Registered"); } if (ModelState.IsValid && user == null) { db.SSignUps.Add(signUp); db.SaveChanges(); return(RedirectToAction("StudentDashBoard")); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes"); } return(View(signUp)); } }
public ActionResult Login(SSignUp entity) { using (KGEntities db = new KGEntities()) { SSignUp user = db.SSignUps.FirstOrDefault(u => u.UserID == (entity.UserID)); TSignUp teacher = db.TSignUps.FirstOrDefault(t => t.UserID == (entity.UserID)); ASignUp admin = db.ASignUps.FirstOrDefault(a => a.UserID == (entity.UserID)); if (user == null || teacher == null || admin == null) { TempData["ErrorMessage"] = "Object not found"; return(View(entity)); } int c = entity.Password.Count(); if (user.Password.Substring(0, c) != entity.Password || teacher.Password.Substring(0, c) != entity.Password || admin.Password.Substring(0, c) != entity.Password) { TempData["ErrorMessage"] = "Password do not Match"; return(View(entity)); } if (user != null || teacher != null || admin != null) { if (user.Password.Substring(0, c) == entity.Password) { return(RedirectToAction("StudentDashBoard")); } if (teacher.Password.Substring(0, c) == entity.Password) { return(RedirectToAction("TeacherDashBoard", "TSignUp")); } if (admin.Password.Substring(0, c) == entity.Password) { return(RedirectToAction("AdminDashBoard", "ASignUp")); } return(View(entity)); } return(View(entity)); } }