public ActionResult getCompteContrat()
        {
            try
            {
                var dashmodel = new AgregDashboardModel();
                if (Request.Form["idCgp"] != null)
                {
                    Guid idCgp = new Guid(Request.Form["idCgp"]);
                    var clientCompteSupportCollection = agupsideocompteBL.GetClientCompteSupportByCgp(idCgp);
                    //
                    //Save Collection
                    //
                    UpsGridVMSession.Current.data = clientCompteSupportCollection;
                    //
                    var comptespea = clientCompteSupportCollection.Where(l => l.typecontrat.ToLower() == agupsideocompteBL.comptetitrespea.ToLower() && l.pea == "o");
                    var comptesnonpea = clientCompteSupportCollection.Where(l => l.typecontrat.ToLower() == agupsideocompteBL.comptetitrespea.ToLower() && l.pea == "n");
                    var comptesassurancevie = clientCompteSupportCollection.Where(l => l.typecontrat.ToLower() == agupsideocompteBL.assurancevie.ToLower());
                    var comptescapitalisation = clientCompteSupportCollection.Where(l => l.typecontrat.ToLower() == agupsideocompteBL.capitalisation.ToLower());


                    dashmodel.CompteTitrePEA = comptespea.GroupBy(x => x.Idfrontcompte).Count();
                    dashmodel.CompteTitreNonPEA = comptesnonpea.GroupBy(x => x.Idfrontcompte).Count();
                    dashmodel.AssuranceVie = comptesassurancevie.GroupBy(x => x.Idfrontcompte).Count();
                    dashmodel.Capitalisation = comptescapitalisation.GroupBy(x => x.Idfrontcompte).Count();


                    var valorisation = comptespea.Sum(x => (x.qte == 1 && x.vl == 0) ? x.pru : x.qte * x.vl);
                    dashmodel.CompteTitrePEAValorisation = valorisation / 1000000;

                    valorisation = comptesnonpea.Sum(x => (x.qte == 1 && x.vl == 0) ? x.pru : x.qte * x.vl);
                    dashmodel.CompteTitreNonPEAValorisation = valorisation / 1000000;

                    valorisation = comptesassurancevie.Sum(x => (x.qte == 1 && x.vl == 0) ? x.pru : x.qte * x.vl);
                    dashmodel.AssuranceVieValorisation = valorisation / 1000000;

                    valorisation = comptescapitalisation.Sum(x => (x.qte == 1 && x.vl == 0) ? x.pru : x.qte * x.vl);
                    dashmodel.CapitalisationValorisation = valorisation / 1000000;
                    //type
                    dashmodel.type = "1";

                    dashmodel.FondEuro = comptesassurancevie.Sum(x => (x.qte == 1 && x.vl == 0) ? 0 : x.qte * x.vl / 1000000);
                    dashmodel.UniteDecompte = comptesassurancevie.Sum(x => (x.qte == 1 && x.vl == 0) ? x.pru / 1000000 : 0);
                }
                return PartialView("TableauDeBordPartial", dashmodel);
            }
            catch (Exception ex)
            {
                Upsilab.Business.Log.Log.AppendException(ex);
                return Content("Error");
            }
        }
        public ActionResult Index()
        {
            UpsGridVMSession.Current.Release();
            AgregDashboardModel dashboardmodel = new AgregDashboardModel();
            try
            {
                Guid idCgp = Guid.Empty;

                var currentUser = SessionManager.GetUserSession();
                if (currentUser != null && currentUser.idAgregCGP.HasValue)
                {
                    idCgp = currentUser.idAgregCGP.Value;
                    SessionManager.Set<Guid>(AgregIdCgpSessionKey, idCgp);


                    if (currentUser.IsEndUser())
                    {
                        CustomerProspect currentCustomer = SessionManager.GetCustomerProspectSession();
                        User currenttUserCreated = currentCustomer.User1;
                        idCgp = currenttUserCreated.idAgregCGP.Value;
                    }

                    var cgp = AgregCgpBL.GetCgpById(idCgp);
                    var firm = FirmInstitutionBL.GetFirmInstitutionByIdAgregCabinet(cgp.idcrmcabinet);

                    SessionManager.Set<Guid>(UserBL.AgregCurrentUserFirmId, firm.idFirmInstitution);
                }
               
                dashboardmodel.idCgp = idCgp.ToString();
                //IdFirmInstitutionType                
                var firminstitution = SessionManager.GetFirmInstitutionSession();                
                dashboardmodel.IdFirmInstitutionType = firminstitution.IdFirmInstitutionType;

                if (Request.Params["pagesize"] != null)
                {
                    var pagesize=Request.Params["pagesize"];
                    ViewBag.pagesize = int.Parse(pagesize.ToString());
                }
                else
                    ViewBag.pageSize = 10;
            }
            catch (Exception ex)
            {
                Upsilab.Business.Log.Log.AppendException(ex);
            }
            return View(dashboardmodel);
        }
 public ActionResult getEvolutionEncour()
 {
     try
     {
         AgregDashboardModel dashboardmodel = new AgregDashboardModel();
         if (Request.Form["idCgp"] != null)
         {
             Guid idCgp = new Guid(Request.Form["idCgp"]);
             //Évolution des encours 
             List<AgregChart> lstevolution = new List<AgregChart>();
             lstevolution = agupsideocompteBL.GetCompteHistoByIdCgp(idCgp);
             string xmlDataEvolution = ChartBL.GetChartMSLineTag(lstevolution);
             //Create the chart - Msline Chart with data contained in xmlData   
             string chartevolution = FusionCharts.RenderChart(Url.Content("~/Content/FusionCharts/MSLine.swf"), "", xmlDataEvolution, "evolutionChartId", "320", "220", false, true, true, "FFFFFF", "noscale", "EN");
             dashboardmodel.ChartEncour = chartevolution;
             //type
             dashboardmodel.type = "4";
         }
         return PartialView("TableauDeBordPartial", dashboardmodel);
     }
     catch (Exception ex)
     {
         Upsilab.Business.Log.Log.AppendException(ex);
         return Content("Error");
     }
 }
        public ActionResult GetOpcvm(string textToSearch, bool isSearch = false, int pagesize = 10)
        {
            try
            {
                
                AgregDashboardModel dashboardmodel = new AgregDashboardModel();
                Guid idCgp;
                SessionManager.Get<Guid>(AgregIdCgpSessionKey, out idCgp);
                if (Request.Form["idCgp"] != null)
                {
                    idCgp = new Guid(Request.Form["idCgp"].ToUpper());
                }
                if (Request.Params["page"] != null)
                {
                    SessionManager.Get<string>(AgregTextToSearchSessionKey, out textToSearch);
                    SessionManager.Get<bool>(AgregIsSearchSessionKey, out isSearch);
                }
                else
                {
                    SessionManager.Set<string>(AgregTextToSearchSessionKey, textToSearch);
                    SessionManager.Set<bool>(AgregIsSearchSessionKey, isSearch);
                }
                                
                if(idCgp != null)
                {
                    //
                    //Table opcvm
                    //
                    /*var ListeOPCVM =
                        (UpsGridVMSession.Current.data == null || !(UpsGridVMSession.Current.data is List<AgregSupport>)) ?
                        agupsideocompteBL.GetTop10OPCVM(idCgp) :
                        UpsGridVMSession.Current.data as List<AgregSupport>;
                    UpsGridVMSession.Current.data = ListeOPCVM;*/
                    var ListeOPCVM = agupsideocompteBL.GetTop10OPCVM(idCgp);
                    //
                    //
                    //
                    if (string.IsNullOrWhiteSpace(textToSearch) || textToSearch.Equals("TOUS"))
                        dashboardmodel.Top10opcvm = ListeOPCVM;
                    else
                    {
                        textToSearch = textToSearch.ToUpper();
                        dashboardmodel.Top10opcvm = (isSearch) ?
                            ListeOPCVM.Where(x => (!string.IsNullOrEmpty(x.Codeisin) && x.Codeisin.ToUpper().Contains(textToSearch)) || (!string.IsNullOrEmpty(x.Nomsupport) && x.Nomsupport.ToUpper().Contains(textToSearch))).ToList() :
                            ListeOPCVM.Where(x => (!string.IsNullOrEmpty(x.Codeisin) && x.Codeisin.ToUpper().StartsWith(textToSearch)) || (!string.IsNullOrEmpty(x.Nomsupport) && x.Nomsupport.ToUpper().StartsWith(textToSearch))).ToList();
                    }
                    dashboardmodel.type = "5";
                    ViewBag.pageSize = pagesize;

                }
                return PartialView("TableauDeBordPartial", dashboardmodel);
            }
            catch (Exception ex)
            {
                Upsilab.Business.Log.Log.AppendException(ex);
                return Content("Error");
            }
        }
 public ActionResult getRepartitionClasseActif()
 {
     try
     {
         AgregDashboardModel dashboardmodel = new AgregDashboardModel();
         if (Request.Form["idCgp"] != null)
         {
             Guid idCgp = new Guid(Request.Form["idCgp"]);
             //Répartition des actifs par classes d'actifs 
             List<AgregChart> lstrepartitionclasse = new List<AgregChart>();
             lstrepartitionclasse = agupsideocompteBL.GetActifClasseByIdCgp(idCgp);
             var lstFiltered = lstrepartitionclasse.Where(c => c.value > 0).ToList();
             string xmlDataClasse = ChartBL.GetChartDougnhutWithList(lstFiltered);
             //Create the chart - Column 2D Chart with data contained in xmlData   
             string chartclasse = FusionCharts.RenderChart(Url.Content("~/Content/FusionCharts/Doughnut2D.swf"), "", xmlDataClasse, "actifChartId", "620", "250", false, true, true, "FFFFFF", "noscale", "EN");
             dashboardmodel.ChartActif = chartclasse;
             //type
             dashboardmodel.type = "3";
             NumberFormatInfo nfi = new NumberFormatInfo { NumberGroupSeparator = " " };
             dashboardmodel.TotalActif = lstrepartitionclasse.Sum(x => x.value).ToString("n0", nfi);
         }
         return PartialView("TableauDeBordPartial", dashboardmodel);
     }
     catch (Exception ex)
     {
         Upsilab.Business.Log.Log.AppendException(ex);
         return Content("Error");
     }
 }