public ActionResult Index() { //ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; string usertype=(string)Session["TypeOfUser"]; Console.WriteLine(Session["TypeOfUser"]); if (Session["TypeOfUser"] == null) { return RedirectToAction("Login", "Account"); } else if (usertype.CompareTo("Admin") == 0) { //return View("AdminLoginPage"); return RedirectToAction("Index","Admin"); } else if (usertype.CompareTo("Applicant") == 0) { string username=(string)Session["Username"]; int userid = new DataAccess.DataObj().GetUserID(username); string name = new DataAccess.DataObj().GetName(username); Session["UserID"] = userid; Session["Name"] = name; return RedirectToAction("Index", "Applicant"); //return View("ApplicantLoginPage"); } else if (usertype.CompareTo("Representative") == 0) { return RedirectToAction("Index", "Representative"); } return View(); }
// // GET: /Applicant/ public ActionResult Index() { string type = (string)Session["TypeOfUser"]; if (type == null) { return RedirectToAction("Index", "Home"); } else if (type.CompareTo("Applicant") != 0) { return RedirectToAction("Index", "Home"); } int userID=(int)Session["UserID"]; int jobs=new DataAccess.DataObj().applicantAppliedJob(userID); int workshop=new DataAccess.DataObj().applicantAppliedWorkshop(userID); int training = new DataAccess.DataObj().applicantAppliedTraining(userID); ViewBag.job = Convert.ToString(jobs); ViewBag.works = Convert.ToString(workshop); ViewBag.train = Convert.ToString(training); return View(); }
public ActionResult Register(Applicant model) { if (ModelState.IsValid) { // Attempt to register the user try { int n = new DataAccess.DataObj().InsertUser(model); Session["UserID"] = n; return RedirectToAction("Index", "Home"); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return View(model); }
public ActionResult Manage(ChangePassword model) { if (ModelState.IsValid) { // ChangePassword will throw an exception rather than return false in certain failure scenarios. string username = (string)(Session["Username"]); bool n = new DataAccess.DataObj().ChangePassword(username, model.OldPassword, model.NewPassword); } return View(model); }
public ActionResult Login(LoginPage model, string returnUrl) { if (ModelState.IsValid) { bool result = new DataAccess.DataObj().validateUser(model.UserName, model.Password, model.TypeOfUser); if (result == true) { Session["Username"] = model.UserName; Session["TypeOfUser"] = model.TypeOfUser; FormsAuthentication.SetAuthCookie(model.UserName, true); //Session["Username"] = "******"; return RedirectToAction("Index","Home"); } } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return View(model); }
// // GET: /Representative/ public ActionResult Index() { string type = (string)Session["TypeOfUser"]; if (type == null) { return RedirectToAction("Index", "Home"); } else if (type.CompareTo("Representative") != 0) { return RedirectToAction("Index", "Home"); } int repid=(int)Session["UserID"]; int job = new DataAccess.DataObj().representativeTotalJobApplication(repid); int training = new DataAccess.DataObj().representativeTotalTrainingApplication(repid); int workshop = new DataAccess.DataObj().representativeTotalWorkshopApplication(repid); ViewBag.jobs = job; ViewBag.train = training; ViewBag.work = workshop; return View(); }
public ActionResult ManagePassword(PasswordChange model) { if (ModelState.IsValid) { // ChangePassword will throw an exception rather than return false in certain failure scenarios. string username = (string)(Session["Username"]); string usertype=(string)Session["TypeOfUser"]; bool val = new DataAccess.DataObj().ChangePassword(username, model.OldPassword, model.NewPassword,usertype); if (val == false) { return View("ErrorChangePassword"); //go to error page } } return RedirectToAction("Login"); }
// // GET: /Admin/ public ActionResult Index() { string type = (string)Session["TypeOfUser"]; if (type == null) { return RedirectToAction("Index", "Home"); } else if (type.CompareTo("Admin") != 0) { return RedirectToAction("Index", "Home"); } int work = new DataAccess.DataObj().adminTotalWorkshopApplication(); ViewBag.totalworkshopapplication = work; int training = new DataAccess.DataObj().adminTotalTrainingApplication(); ViewBag.totaltrainingapplication = training; int job = new DataAccess.DataObj().adminTotalJobApplication(); ViewBag.totaljobapplication = job; return View(); }