public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            try
            {
                //Call Login Repo
                LoginRepo logs = new LoginRepo();

                // If Data is Valid.
                if (ModelState.IsValid)
                {
                    HttpClient client = new HttpClient();
                    string     url    = "http://localhost:11905/api/CIFOnlineUser";
                    client.BaseAddress = new Uri(url);
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HttpResponseMessage response = await client.GetAsync(url + "/" + model.Username + "/" + model.Password);


                    if (response.IsSuccessStatusCode)
                    {
                        //continue business logic

                        var responseData = response.Content.ReadAsStringAsync().Result;
                        var employee     = JsonConvert.DeserializeObject <EmpData>(responseData);

                        Global.ID            = employee.ID;
                        Global.LastName      = employee.FirstName.ToString();
                        Global.MiddleName    = employee.MiddleName.ToString();
                        Global.FirstName     = employee.FirstName.ToString();
                        Global.AccountName   = employee.AccountName.ToString();
                        Global.Cifkey        = employee.Cifkey.ToString();
                        Global.LastLoginDate = employee.LastLoginDate;
                        Global.Birthdate     = employee.Birthdate;
                        Global.EmailAddress  = employee.EmailAddress.ToString();
                        Global.UserName      = employee.Username.ToString();
                        Global.Gender        = employee.Sex.ToString();
                        Global.Branchcode    = employee.Branchcode.ToString();
                        Global.AcctGuid      = employee.GUID;

                        //Insert Login Logs
                        //logs.InsertLoginLog(employee.ID);

                        //Update cifonlineusers lastlogindate
                        logs.UpdateClientLoginDate(employee.ID, employee.GUID);


                        //create  cookies account
                        HttpCookie usernameCookie = new HttpCookie("username", Global.UserName);
                        Response.Cookies.Add(usernameCookie);
                        HttpCookie AcctNameCookie = new HttpCookie("acctName", Global.AccountName);
                        Response.Cookies.Add(AcctNameCookie);

                        //Apply OWIN authentication
                        this.SignInUser(model.Username, false);

                        return(this.RedirectToLocal(returnUrl));
                    }
                    else
                    {
                        //**********************************************************************************************//
                        // 3 Attempt login  NOT YET FINISH
                        //**********************************************************************************************//
                        Session["LoginCount"] = Convert.ToInt32(Session["LoginCount"]) + 1;
                        if (Convert.ToInt32(Session["LoginCount"]) == 3)
                        {
                            //Change Account Status to Locked and client must call coop. based in username ang ma locked nya
                            //www.aspdotnet-pools.com/2017/03/lock-user-account-on-three-failed-login.html

                            //DeActivate Account()
                            ModelState.AddModelError(string.Empty, "Login Failed. You are not an Authorized User.");
                            return(View(model));
                        }
                        else
                        {
                            int countattempt = 3 - Convert.ToInt32(Session["LoginCount"]);
                            ModelState.AddModelError(string.Empty, "Login Failed. Require correct username and password. " + countattempt + " Attempt Remaining.");
                            return(View(model));
                        }
                    }
                }

                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid Credential Provided.");
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            // If we got this far, something failed, redisplay form
            return(View(model));
        }