Пример #1
0
        public ActionResult Index()
        {
            int    id         = 0;
            string userPerson = "";

            if (Session["userId"] != null)
            {
                userPerson = Session["userId"].ToString();
            }
            id = int.Parse(userPerson);
            var userInfo     = pocoDb.Fetch <tblUser>(" WHERE userID=@0", id).FirstOrDefault();
            var UserName     = userInfo.userName;
            var UserPassword = userInfo.userPassword;

            if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(UserPassword))
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (ModelState.IsValid)
            {
                var user = pocoDb.Fetch <tblUser>(" WHERE userName = @0 and userPassword=@1", UserName, UserPassword).FirstOrDefault();
                if (user != null)
                {
                    Session["username"] = UserName;
                    Session["userId"]   = user.userID;
                    var solutions = pocoDb.Fetch <tblSolution>(" WHERE isActive=1");

                    var VM = new ClientPortal.ViewModels.LoginViewModel
                    {
                        Solutions = solutions
                    };

                    return(View(VM));
                }
                else
                {
                    Session["LoginErrorMessage"] = "Invalid Username or password";
                    return(View("Login", Session["LoginErrorMessage"]));
                }
            }
            return(RedirectToAction("Login", "Home"));
        }
Пример #2
0
        public ActionResult Search(string searchString)
        {
            if (string.IsNullOrEmpty(searchString))
            {
                var tblSolutions = pocoDb.Fetch <tblSolution>("Where isActive=1").ToList();
                var titleList    = tblSolutions.Select(x => x.solutionTitle).ToList();
                var Solution     = new ClientPortal.ViewModels.LoginViewModel
                {
                    Solutions = tblSolutions
                };

                return(View(Solution));
            }
            else
            {
                var selectedTitle = pocoDb.Fetch <tblSolution>("Where solutionTitle LIKE @0", "%" + searchString + "%").ToList();
                var VMSolution    = new ClientPortal.ViewModels.LoginViewModel
                {
                    Solutions = selectedTitle
                };

                return(PartialView(VMSolution));
            }
        }