public ActionResult Login(UserLoginViewModel objEntity)
        {
            var objAccountRepository = new AccountRepository();
            if (ModelState.IsValid)
            {
                objEntity.UserEmail = objEntity.UserEmail.Trim();
                objEntity.Password = objEntity.Password.Trim();

                var objUserViewModel = objAccountRepository.CheckSignIn(UserFlags.UserSignIn.GetHashCode(), objEntity);
                if (objUserViewModel != null)
                {

                    SessionWrapper.UserAccount = new AccountRepository().GetAccountByUser(objUserViewModel);

                    FormsAuthentication.SetAuthCookie(Convert.ToString(objUserViewModel.UserId), false);

                    if (SessionWrapper.UserAccount.UserTypeID == UserTypes.User.GetHashCode())
                    {
                        return RedirectToAction("Dashboard", "User");
                    }
                    else if (SessionWrapper.UserAccount.UserTypeID == UserTypes.Admin.GetHashCode())
                    {
                        return RedirectToAction("Dashboard", "Admin");
                    }

                }
                else
                {
                    this.Flash("error", "We didn't recognize the username or password you entered. Please try again");

                }

            }
            return View(objEntity);
        }
        public UserViewModel CheckSignIn(int flag, UserLoginViewModel objEntity)
        {
            var objUserViewModel = new UserViewModel
            {
                UserEmail = objEntity.UserEmail,
                Password = objEntity.Password

            };
            return _userRepository.Select(flag, objUserViewModel).FirstOrDefault();
        }
        public ActionResult Login(UserLoginViewModel objEntity)
        {
            if (ModelState.IsValid)
            {
                objEntity.UserEmail = objEntity.UserEmail.Trim();
                objEntity.Password = objEntity.Password.Trim();

                if (ValidateUser(objEntity) == LoginResultEnum.Success.GetHashCode())
                {
                    return RedirectToAction("Dashboard", "Admin");

                }
                else if (ValidateUser(objEntity) == LoginResultEnum.Unauthorized.GetHashCode())
                {
                    this.Flash("Error", "Unauthorized access to Admin accounts");
                }

                else
                {
                    this.Flash("Error", "We didn't recognize the username or password you entered. Please try again");

                }

            }
            return View(objEntity);
        }
        public int ValidateUser(UserLoginViewModel objEntity)
        {
            int isResult = LoginResultEnum.Failure.GetHashCode();
            AccountRepository objAccountRepository = new AccountRepository();
            var objUserViewModel = objAccountRepository.GetUserDetailsforLogin(UserFlags.UserSignIn.GetHashCode(), objEntity);
            if (objUserViewModel != null)
            {
                if (objUserViewModel.RoleId == RoleUserDefinedEnum.Admin.GetHashCode())
                {

                    if (PasswordHelpers.Validate(objUserViewModel.Password, objUserViewModel.PasswordSalt, objEntity.Password))
                    {
                        isResult = AccountRepository.Login(objUserViewModel);

                    }
                }
                else
                {
                    isResult = LoginResultEnum.Unauthorized.GetHashCode();
                }

            }

            return isResult;
        }
        public UserViewModel GetUserDetailsforLogin(int flag, UserLoginViewModel objEntity)
        {
            var objUserViewModel = new UserViewModel
            {
                UserEmail = objEntity.UserEmail

            };
            return _userRepository.Select(flag, objUserViewModel).FirstOrDefault();
        }