Ejemplo n.º 1
0
        // GET: Abonnement/Create
        public ActionResult Souscrire()
        {
            AbonnementViewModels aboViewModels = new AbonnementViewModels();
            var allTypeAbonnement = bdd.TypeAbonnementModels.Include("TarifModels");

            aboViewModels.TypeAbo        = allTypeAbonnement.ToList();
            aboViewModels.TypeAboPossede = new List <TypeAbonnementModels>();
            CarteModels             carteUser   = carte.findCarteByUser(User.Identity.Name);
            List <AbonnementModels> aboUserList = carteUser.AbonnementsModels.ToList();

            if (aboUserList != null)
            {
                foreach (AbonnementModels abo in aboUserList)
                {
                    int typeAboId = abo.TypeAbonnementModelsID;
                    TypeAbonnementModels typeAbo = bdd.TypeAbonnementModels.Find(typeAboId);
                    if (typeAbo != null)
                    {
                        string intitule = typeAbo.Intitule;
                        aboViewModels.TypeAboPossede.Add(typeAbo);
                        aboViewModels.TypeAbo.Remove(typeAbo);
                    }
                }
            }
            return(View(aboViewModels));
        }
Ejemplo n.º 2
0
 public ActionResult Index()
 {
     try
     {
         HomeViewModels homeViewModel = new HomeViewModels();
         //nbTicket
         CarteModels carte    = carteRepository.findCarteByUser(User.Identity.Name);
         int         nbTicket = carte.TicketModels.Count;
         homeViewModel.nbTicket = nbTicket;
         //abonnement souscrit
         int nbAboSouscrit = carte.AbonnementsModels.Count;
         homeViewModel.nbAbo = nbAboSouscrit;
         var           enumAbo      = carte.AbonnementsModels.GetEnumerator();
         List <string> intituleList = new List <string>();
         while (enumAbo.MoveNext())
         {
             AbonnementModels item        = enumAbo.Current;
             int idType                   = item.TypeAbonnementModelsID;
             TypeAbonnementModels typeAbo = Context.TypeAbonnementModels.Find(idType);
             intituleList.Add(typeAbo.Intitule);
         }
         homeViewModel.intituleList = intituleList;
         return(View(homeViewModel));
     }
     catch (Exception e)
     {
         HomeViewModels homeView = new HomeViewModels();
         homeView.nbTicket     = 0;
         homeView.nbAbo        = 0;
         homeView.intituleList = new List <string>();
         return(View(homeView));
     }
 }