Beispiel #1
0
        public ActionResult Login(string UserEmail, string UserPassword, string RememberMe)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(UserEmail.Trim()))
                {
                    Error("UserEmail not filled not correctly");
                    //ModelState.AddModelError("", "UserEmail not filled not correctly");
                    return(View());
                }
                else if (string.IsNullOrEmpty(UserPassword.Trim()))
                {
                    Error("Must fill password field");
                    //ModelState.AddModelError("", "Must fill password field");
                    return(View());
                }

                try
                {
                    ModelAdminUser objAdminUser = new ModelAdminUser();
                    DataTable      userDetails  = new DataTable();
                    userDetails = bllAdminUser.GetAdminUserDetailsByLogin(UserEmail, UserPassword);
                    if (userDetails.Rows.Count > 0)
                    {
                        objAdminUser.UserAccountNo    = Convert.ToInt32(userDetails.Rows[0]["intAdminUserId"]);
                        objAdminUser.UserName         = Convert.ToString(userDetails.Rows[0]["strAdminUserName"]);
                        objAdminUser.UserFirstName    = Convert.ToString(userDetails.Rows[0]["strAdminUserFirstName"]);
                        objAdminUser.UserLastName     = Convert.ToString(userDetails.Rows[0]["strAdminUserLastName"]);
                        objAdminUser.UserEmail        = Convert.ToString(userDetails.Rows[0]["strAdminUserEmail"]);
                        objAdminUser.UserProfileImage = Convert.ToString(userDetails.Rows[0]["ProfileLogo"]);

                        Session[DALVariables.UserAccountId] = objAdminUser.UserAccountNo;
                        Session[DALVariables.UserEmail]     = objAdminUser.UserEmail;
                        Session[DALVariables.UserName]      = objAdminUser.UserFirstName + " " + objAdminUser.UserLastName;
                        Session[DALVariables.ProfileImage]  = objAdminUser.UserName;
                        return(RedirectToAction("Index", "Admin"));
                    }
                    ModelState.AddModelError("", "No User Found ! , Re-check login details");
                    return(View());
                }
                catch (Exception ex)
                {
                    DALUtility.ErrorLog(ex.Message, "AdminController, Login");
                }
            }
            else
            {
                ModelState.AddModelError("", "Fill form Correctly; Please correct to continue!");
            }
            return(View());
        }
        public ActionResult Login(string UserName, string UserPassword, string RememberMe)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    ModelAdminUser objAdminUser = new ModelAdminUser();
                    DataTable      userDetails  = new DataTable();
                    userDetails = bllAdminUser.GetAdminUserDetailsByLogin(UserName, UserPassword);
                    if (userDetails.Rows.Count > 0)
                    {
                        objAdminUser.UserAccountNo    = Convert.ToDouble(userDetails.Rows[0]["AdminUserNo"]);
                        objAdminUser.UserName         = Convert.ToString(userDetails.Rows[0]["AdminUserName"]);
                        objAdminUser.UserFirstName    = Convert.ToString(userDetails.Rows[0]["AdminUserFirstName"]);
                        objAdminUser.UserLastName     = Convert.ToString(userDetails.Rows[0]["AdminUserLastName"]);
                        objAdminUser.UserEmail        = Convert.ToString(userDetails.Rows[0]["AdminUserEmail"]);
                        objAdminUser.UserMobileNumber = Convert.ToDouble(userDetails.Rows[0]["AdminUserMobile"]);

                        Session[DALVariables.AdminUserNo]   = objAdminUser.UserAccountNo;
                        Session[DALVariables.UserEmail]     = objAdminUser.UserEmail;
                        Session[DALVariables.UserFirstName] = objAdminUser.UserFirstName;
                        Session[DALVariables.UserLastName]  = objAdminUser.UserLastName;
                        Session[DALVariables.UserName]      = objAdminUser.UserName;
                        //Session[DALVariables.ProfileImage] = "";
                        return(RedirectToAction("Index", "Admin"));
                    }
                    ModelState.AddModelError("", "No User Found!,Re-check login details");
                    return(View());
                }
                catch (Exception ex)
                {
                    DALUtility.ErrorLog(ex.Message, "AdminController, Login");
                }
            }
            else
            {
                ModelState.AddModelError("", "Check error of form; Please correct to continue!");
            }
            return(View());
        }