Exemplo n.º 1
0
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                int IsUserValidated = (from dt in db2.personalDetails where dt.email == model.email && dt.password == model.Password select dt).Count();
                if (IsUserValidated > 0)
                {
                    FormsAuthentication.SetAuthCookie(model.email, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return Redirect(returnUrl);

                    }
                     else
                    {
                        string email = model.email.ToString();
                        Session["userID"] = email;
                       // return RedirectToAction("Edit", "personalDetail", new { email = model.email, id = 0 });
                        return RedirectToAction("MyAccount", "personalDetail", new { email = model.email, id = 0 });
                       // return RedirectToAction("Index", "Home");
                    }
                }
                //if (Membership.ValidateUser(model.UserName, model.Password))
                //{
                //    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                //    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                //        && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                //    {
                //        return Redirect(returnUrl);
                //    }
                //    else
                //    {
                //        return RedirectToAction("Index", "Home");
                //    }
                //}
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult EmployerLogin(LogOnModel model)
        {
            if (ModelState.IsValid)
            {

                employerRegistration empRegistration = (from dt in db2.employerRegistrations where dt.employerLoginName == model.email && dt.password == model.Password select dt).SingleOrDefault();
                if (empRegistration != null)
                {
                    Session["empUserName"] = model.email;
                    return RedirectToAction("JobPost", "Employer", new { employerId = empRegistration.employerid, id = 0 });
                }
                else
                {
                    ModelState.AddModelError("", "The employer ID name or password provided is incorrect.");
                    return View(model);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }