public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                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
                    {
                        TempData["Username"] = model.UserName;
                        LinqModelHelperDataContext dbcontext = new LinqModelHelperDataContext();
                        var dbuser = from u in dbcontext.Users
                                       where u.Login == model.UserName
                                       select u;
                        User user = dbuser.First();
                        if (user.UserType == 1)
                            //return RedirectToAction("IndexRecruiter", "Home");
                            return RedirectToAction("Index", "Recruiter1", new { username = user.Login }); //, new RouteValueDictionary(model.UserName));
                        return RedirectToAction("Index", "JobSeeker", new { username = user.Login }); //, new RouteValueDictionary(model.UserName));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
        public ActionResult Register(RegisterModel model)
        {
            //if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);

                    // Save user to DB
                    LinqModelHelperDataContext dbcontext = new LinqModelHelperDataContext();
                    Guid userID = Guid.NewGuid();
                    Models.User user = new Models.User();
                    user.UserID = userID;
                    user.FirstName = model.UserName;
                    user.LastName = model.UserName;
                    user.Login = model.UserName;
                    user.UserType = (short)model.UserType;
                    user.LastLogin = DateTime.Now;
                    user.Email = model.Email;
                    user.City = model.City;
                    user.State = model.State;
                    user.Country = model.Country;
                    user.Zip = model.Zip;
                    user.WillingToRelocate = model.WillingToRelocate;
                    dbcontext.Users.InsertOnSubmit(user);
                    for (int i = 1; i <= Int32.Parse(Request.Form["skillIndex"]); i++)
                    {
                        string skill = Request.Form["Skill" + i.ToString()];
                        string year = Request.Form["Year" + i.ToString()];
                        if (skill != String.Empty && year != string.Empty)
                        {
                            Models.UserSkill userskill = new Models.UserSkill();
                            userskill.UserSkillID = Guid.NewGuid();
                            userskill.UserID = user.UserID;
                            userskill.Skill = skill;
                            userskill.Year = (short)Int32.Parse(year);
                            dbcontext.UserSkills.InsertOnSubmit(userskill);
                        }
                    }
                    dbcontext.SubmitChanges();

                    TempData["Username"] = model.UserName;
                    if (user.UserType == 1)
                        return RedirectToAction("Index", "Recruiter1", new { username = model.UserName });
                    return RedirectToAction("Index", "JobSeeker", new { username = model.UserName });
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

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