public ActionResult Connection(string ConnectionDtl, string Action)
        {
            if (Session["LinkToken"] != null)
            {
                ViewBag.LinkToken = Session["LinkToken"];
            }
            if (!string.IsNullOrEmpty(Action) && Session["LoginDtl"] != null)
            {
                ActionClass obj = JsonConvert.DeserializeObject <ActionClass>(Action);
                if (obj.Action.Equals("Go"))
                {
                    using (PlaidEntities DB = new PlaidEntities())
                    {
                        string AccessToken = DB.tblInstances.Where(x => x.ConnectionId == obj.Id).Select(x => x.AccessToken).FirstOrDefault().ToString();
                        Session["AccessToken"] = Base64Decode(AccessToken.Trim());
                        return(RedirectToAction("Holding"));
                    }
                }
                else if (obj.Action.Equals("Delete"))
                {
                    using (PlaidEntities DB = new PlaidEntities())
                    {
                        tblInstance RemoveInstances = DB.tblInstances.Where(x => x.ConnectionId == obj.Id).Select(x => x).FirstOrDefault();
                        if (RemoveInstances != null)
                        {
                            DB.tblInstances.Remove(RemoveInstances);
                            DB.SaveChanges();
                        }
                        List <tblInstance> Instances = DB.tblInstances.Select(x => x).ToList <tblInstance>();
                        return(View(Instances));
                    }
                }
                else if (obj.Action.Equals("Save"))
                {
                    using (PlaidEntities DB = new PlaidEntities())
                    {
                        var result = DB.tblInstances.SingleOrDefault(b => b.ConnectionId == obj.Id);
                        if (result != null)
                        {
                            result.InstanceName = obj.InstanceName;
                            DB.SaveChanges();
                        }
                        //List<tblInstance> Instances = DB.tblInstances.Select(x => x).ToList<tblInstance>();
                        //return View(Instances);
                        RedirectToAction("Connection");
                    }
                }
                else if (obj.Action.Equals("Cancel"))
                {
                    return(View());
                }
                else
                {
                    return(View());
                }
            }
            else if (!string.IsNullOrEmpty(ConnectionDtl) && Session["LoginDtl"] != null)
            {
                tblInstance obj = JsonConvert.DeserializeObject <tblInstance>(ConnectionDtl);
                PublicTokenExchangeResponse publicTokenEx = helper.GetAccessToken(obj.PublicToken.Trim());
                if (string.IsNullOrEmpty(publicTokenEx.ErrorCode))
                {
                    tblUser loginDtl = (tblUser)Session["LoginDtl"];
                    obj.UserId      = loginDtl.Id;
                    obj.AccessToken = Base64Encode(publicTokenEx.AccessToken.Trim());
                    obj.PublicToken = Base64Encode(obj.PublicToken.Trim());
                    using (PlaidEntities DB = new PlaidEntities())
                    {
                        DB.tblInstances.Add(obj);
                        DB.SaveChanges();
                    }
                }
            }

            return(RedirectToAction("Connection"));
            //using (PlaidEntities DB = new PlaidEntities())
            //{
            //    List<tblInstance> Instances = DB.tblInstances.Select(x => x).ToList<tblInstance>();
            //    return View(Instances);
            //}
        }