public ActionResult Login(LoginViewModel l, string ReturnUrl = "")
        {
            string password = encryptpass(l.Password);

            using (OnlineRecruitmentDBEntities db = new OnlineRecruitmentDBEntities())
            {
                var users = db.tblUsers.Where(a => a.Username == l.Username && a.Password == password).FirstOrDefault();
                if (users != null)
                {
                    username = l.Username;
                    FormsAuthentication.SetAuthCookie(l.Username, l.RememberMe);
                    if (Url.IsLocalUrl(ReturnUrl))
                    {
                        return(Redirect(ReturnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    var usrnme = db.tblUsers.Where(a => a.Username == l.Username).FirstOrDefault();
                    if (usrnme == null)
                    {
                        ModelState.AddModelError("", "Invalid User");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Incorrect Password");
                    }
                }
            }
            return(View());
        }
 public override string[] GetRolesForUser(string username)
 {
     using (OnlineRecruitmentDBEntities objContext = new OnlineRecruitmentDBEntities())
     {
         var objUser = objContext.tblUsers.FirstOrDefault(x => x.Username == username);
         if (objUser == null)
         {
             return(null);
         }
         else
         {
             string[] ret = objUser.tblUserRoles.Select(x => x.tblRole.RoleName).ToArray();
             return(ret);
         }
     }
 }