public ActionResult Login(LoginModel model, string returnUrl)
        {
            try
            {
                var organizationID = OrganizationUtility.GetOrganizationID(Request.Url.AbsoluteUri);

                if (ModelState.IsValid && organizationID != null)
                {
                    if (LoginVerification.ValidateUser(model.UserName, model.Password, (int)organizationID))
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                        if (SessionManagement.UserInfo.LogAccountType == LoginAccountType.LiveAccount)
                        {
                            return(RedirectToAction("Index", "Dashboard"));
                        }
                        //If Introducing Broker
                        else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_IB)
                        {
                            return(RedirectToAction("Index", "Dashboard", new { Area = "IntroducingBroker" }));
                        }
                        //If Asset Manager
                        else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_AM)
                        {
                            return(RedirectToAction("Index", "Profile", new { Area = "AssetManager" }));
                        }
                        //If Super Admin
                        else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_SUPERADMIN)
                        {
                            return(RedirectToAction("Index", "Dashboard", new { Area = "SuperAdmin" }));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Some error occurred!");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "The user name or password provided is incorrect.");
                    }
                }


                return(View(model));
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }
        public ActionResult Login(string returnUrl)
        {
            try
            {
                //Check Whether User is already Authenticated
                if (SessionManagement.IsLoginAuthenticated)
                {
                    if (SessionManagement.UserInfo.LogAccountType == LoginAccountType.LiveAccount)
                    {
                        return(RedirectToAction("Index", "Dashboard"));
                    }
                    //If Introducing Broker
                    else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_IB)
                    {
                        return(RedirectToAction("Index", "Dashboard", new { Area = "IntroducingBroker" }));
                    }
                    //If Asset Manager
                    else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_AM)
                    {
                        return(RedirectToAction("Index", "Profile", new { Area = "AssetManager" }));
                    }
                    //If Super Admin
                    else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_SUPERADMIN)
                    {
                        return(RedirectToAction("Index", "Dashboard", new { Area = "SuperAdmin" }));
                    }
                }

                //Check for the existing organization from the URL
                var organizationID = OrganizationUtility.GetOrganizationID(Request.Url.AbsoluteUri);
                if (organizationID != null)
                {
                    SessionManagement.OrganizationID = organizationID;
                    ViewBag.ReturnUrl = returnUrl;
                    return(View());
                }
                else
                {
                    //Redirect it to page not found.
                    return(RedirectToAction("PageNotFound", "Error"));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }