public async Task <ActionResult> Login(string inputEmail, string inputPassword)
        {
            var url      = "token";
            var response = await HttpClientHelper.ApiTokenCall(url, "password", inputEmail, inputPassword);

            if (response.IsSuccessful)
            {
                var result = response.Content;
                var token  = JsonConvert.DeserializeObject <Models.ViewModels.TokenViewModel>(result);
                AuthenticationProperties options = new AuthenticationProperties();

                options.AllowRefresh = true;
                options.IsPersistent = true;
                options.ExpiresUtc   = DateTime.UtcNow.AddSeconds(token.ExpiresIn);
                System.Web.HttpContext.Current.GetOwinContext().Authentication.SignIn(options);

                //var customer = new CustomerViewModel();
                //var getDomainUrl = "api/account/getdomain/" + token.UserName + "/";
                //response = await HttpClientHelper.ApiCall(getDomainUrl, Method.GET);

                //if (response.IsSuccessful)
                //{
                //    result = response.Content;
                //    customer = JsonConvert.DeserializeObject<CustomerViewModel>(result);

                var claims = new[]
                {
                    //Email Address
                    new Claim(ClaimTypes.Name, token.LastName),
                    //Access Token
                    new Claim("AccessToken", token.AccessToken),
                    //Expiration Date
                    new Claim("ExpiryDate", token.Expires.ToString()),
                    new Claim("Domain", token.Domain),
                    new Claim("CustomerId", token.CustomerId.ToString()),
                    new Claim("FirstName", token.FirstName.ToString()),
                    new Claim("LastName", token.LastName.ToString()),
                    new Claim("MiddleName", token.MiddleName.ToString()),
                    //new Claim("UserName", token.UserName.ToString()),
                    new Claim("EmailAddress", token.UserName.ToString()),
                    new Claim("Image", token.Image.ToString()),
                    new Claim("Role", token.Role.ToString()),
                };

                var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
                var authenticationManager = HttpContext.GetOwinContext().Authentication;
                authenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(new ClaimsPrincipal(identity), new AuthenticationProperties()
                {
                    IsPersistent = true
                });
                //if(CookieHelper.IsInRole("Administrator"))
                //{
                //    return RedirectToAction("Index", "Brand");
                //}
                return(RedirectToAction("Index", "Home"));

                //}
                //Error("An error has occurred");
                //Log.Error(string.Format(Type.GetType(typeof(AccountController).Name) + "||Update||DeliveryRequest ID::{0}||API Response::{1}", token.UserName, response));
                //return RedirectToAction("Login","Account");
            }
            else if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                TempData["LoginMessage"] = "Login failed. Email Address or password supplied does not exist.";
                return(View("Login"));
            }
            else
            {
                return(RedirectToAction("Http403", "Error"));
            }


            //HttpResponseMessage responseMessage = await client.SendAsync(request);
            //if (responseMessage.IsSuccessStatusCode)
            //{

            //    string resultContent = responseMessage.Content.ReadAsStringAsync().Result;
            //    var token = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.ViewModels.TokenViewModel>(resultContent);



            //    //var customer = new CustomerViewModel();
            //    //var getDomainUrl = "api/Account/GetDomain/" + token.UserName;

            //    //var response = await HttpClientHelper.ApiCall(getDomainUrl, Method.GET);

            //    //if (response.IsSuccessful)
            //    //{
            //    //    var result = response.Content;
            //    //    customer = JsonConvert.DeserializeObject<CustomerViewModel>(result);
            //    //    var claims = new[]
            //    //    {
            //    //        //Email Address
            //    //        new Claim(ClaimTypes.Name, token.UserName),
            //    //        //Access Token
            //    //         new Claim("AccessToken", token.AccessToken),
            //    //        //Expiration Date
            //    //        new Claim("ExpiryDate", token.Expires.ToString()),
            //    //        new Claim("Domain", customer.Domain),
            //    //        new Claim("CustomerId", customer.Id.ToString()),
            //    //    };

            //    //    var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);
            //    //    System.Web.HttpContext.Current.GetOwinContext().Authentication.SignIn(options, identity);
            //    //    return RedirectToAction("Index", "Home");
            //    //}
            //    //else
            //    //{
            //    //    return View("Login");
            //    //}


            //}
            //else if (responseMessage.StatusCode == HttpStatusCode.BadRequest)
            //{
            //    TempData["Message"] = "Login failed. Email Address or password supplied doesn't exist.";
            //    return View("Login");
            //}
            //else return RedirectToAction("Http403","Error");
        }