public ActionResult Login(logindetail lg) { var id = db.userdetails.Where(i => i.email == lg.email && i.pass == lg.pass).FirstOrDefault(); if (id.roleid == 1) { Session["UName"] = id.name; return(RedirectToAction("Dashboard", "Admin")); } else if (id.roleid == 2) { Session["UName"] = id.name; return(RedirectToAction("Dashboard", "Client")); } else if (id.roleid == 3) { Session["UName"] = id.name; return(RedirectToAction("Dashboard", "Freelancer")); } else { Session["UName"] = id.name; ViewBag.Error = "Wrong Crediantials Entered!"; } return(View()); }
public bool Registration(string name, string email, string gender, string s_ques, string s_ans, string dbbirth, string mobile, string country, string city, string address) { Registration rg = new Registration(); rg.name = name; rg.email = email; // rg.password = password; rg.gender = gender; rg.a_ques = s_ques; rg.s_ans = s_ans; rg.dob = dbbirth; rg.mobile = mobile; rg.country = country; rg.city = city; rg.address = address; da.Registrations.InsertOnSubmit(rg); logindetail lg = new logindetail(); lg.name = name; //lg.password = password; lg.email = email; lg.s_ques = s_ques; lg.s_ans = s_ans; lg.u_type = "user"; da.logindetails.InsertOnSubmit(lg); ImageDetail img1 = new ImageDetail(); img1.UserID = email; img1.Imagename = ""; img1.ImagePath = ""; da.ImageDetails.InsertOnSubmit(img1); try { da.SubmitChanges(); return(true); } catch { return(false); } }
public ActionResult Index(logindetail inform) { if (ModelState.IsValid) { List <user_info> userDetail = sqlconnection.getuserdetail(inform.username, inform.password, inform.school).ToList(); if (userDetail.Count == 1) { Session["loggedinusername"] = inform.username; Session["loggedinusertype"] = inform.school; Session["loggedinusernameid"] = userDetail[0].id.ToString(); Session["loggedinuserschool"] = inform.school; Session["loggedinuserschoolid"] = userDetail[0].schoolid.ToString(); Session["loggedinusercourseid"] = userDetail[0].courseid.ToString(); if (inform.school == "schooladmin") { return(RedirectToAction("Index", "School")); } else if (inform.school == "teacher") { return(RedirectToAction("Index", "Teacher")); } else if (inform.school == "student") { return(RedirectToAction("Index", "Student")); } else if (inform.school == "superadmin") { return(RedirectToAction("Index", "SuperAdmin")); } } @ViewBag.errormessage = "Incorrect username or password"; } else { @ViewBag.errormessage = "Username/Password cannot be empty"; } return(View()); }