Пример #1
0
        public ActionResult Retour()
        {
            var          welcomeForm         = new WelcomeForm();
            var          welcome             = new Welcome();
            List <Resto> listeDesRestaurants = dal.ObtientTousLesRestaurants();

            welcome.Bdd         = listeDesRestaurants;
            welcome.Sondages    = dal.ObtenirSondages();
            welcomeForm.welcome = welcome;
            welcomeForm.sel     = new SelectList(welcome.Sondages, "Id", "Id");
            return(View("~/Views/Restaurant/Index.cshtml", welcomeForm));
        }
Пример #2
0
 public ActionResult LeNomQueJeVeux()
 {
     //using (IDal dal = new Dal())
     {
         var welcome = new WelcomeForm();
         welcome.welcome = new Welcome();
         List <Resto> listeDesRestaurants = dal.ObtientTousLesRestaurants();
         welcome.welcome.Bdd      = listeDesRestaurants;
         welcome.welcome.Sondages = dal.ObtenirSondages();
         welcome.sel = new SelectList(welcome.welcome.Sondages, "Id", "Id");
         return(View(welcome));
     }
 }
Пример #3
0
        public ActionResult CreerSondage()
        {
            Votes vo = new Votes();

            vo.IdSondage = dal.CreerUnSondage();
            var          welcome             = new WelcomeForm();
            Welcome      welc                = new Welcome();
            List <Resto> listeDesRestaurants = dal.ObtientTousLesRestaurants();

            welc.Bdd        = listeDesRestaurants;
            welc.Sondages   = dal.ObtenirSondages();
            welc.Prenom     = Request.Form["welcome.Prenom"];
            welcome.welcome = welc;
            welcome.sel     = new SelectList(welc.Sondages, "Id", "Id");
            return(View("Index", welcome));
        }
Пример #4
0
 public ActionResult AccederSondage(int?id)
 {
     if (id.HasValue)
     {
         var sondage = dal.ObtenirSondages().FirstOrDefault(Sond => Sond.Id == id);
         if (sondage == null)
         {
             return(View("Error"));
         }
         Votes vo = new Votes();
         vo.IdSondage = sondage.Id;
         var pre = Request.Form["welcome.Prenom"];
         vo.Utilisateur = ObtenirUtilisateurBis(pre);
         if (vo.Utilisateur == null)
         {
             List <Resto> listeDesRestaurants = dal.ObtientTousLesRestaurants();
             var          welcome             = new WelcomeForm();
             Welcome      welc = new Welcome();
             welc.Bdd        = listeDesRestaurants;
             welc.Sondages   = dal.ObtenirSondages();
             welc.Prenom     = pre;
             welcome.welcome = welc;
             welcome.sel     = new SelectList(welc.Sondages, "Id", "Id");
             return(View("Index", welcome));
         }
         var Restos = dal.ObtientTousLesRestaurants();
         vo.Restos = new List <RestaurantCheckBoxViewModel>();
         foreach (var r in Restos)
         {
             var res = new RestaurantCheckBoxViewModel();
             res.Rest           = r;
             res.NomEtTelephone = r.Nom + " " + r.Telephone;
             res.Id             = r.Id;
             vo.Restos.Add(res);
         }
         return(View("~/Views/Vote/Index.cshtml", vo));
     }
     return(View("Error"));
 }
Пример #5
0
        // GET: Vote
        public ActionResult Index2(List <RestaurantCheckBoxViewModel> restos, Utilisateur utilisateur, int?idSondage)
        {
            //var Query = Request.Form[""];
            {
                //StringBuilder Str2 = new StringBuilder();
                //foreach (var r in restos)
                {
                    /*var Sel = Request.Form["Restos[" + Index + "].EstSelectionne"];
                     * var Ind = Request.Form["Restos[" + Index + "].Id"];*/
                    //
                    //Str2.Append(r.EstSelectionne).Append(",");
                    //Str2.Append(r.NomEtTelephone).Append(",");
                    //Str2.Append(r.Id).Append("\n");

                    /*var RestoResult = RestList.FirstOrDefault(Rest => Rest.Id.ToString() == Ind);
                     * if (RestoResult == null)
                     * {
                     *  Index++;
                     *  continue;
                     * }
                     * Str.Append(RestoResult.Nom).Append(",");
                     *
                     * if (Ut != null)
                     * {
                     *  Str.Append(Ut.Prenom).Append("\n");
                     *  dal.AjouterVote(IdSon, RestoResult.Id, Ut.Id);
                     * }
                     * else
                     * {
                     *  Str.Append(Ut).Append("\n");
                     * }
                     * Index++; */
                }
                //File(Encoding.ASCII.GetBytes(Str2.ToString()), "application/octet-stream", "MonFichier.txt");
            }
            //Votes votes = new Votes();
            var Ut = dal.ObtenirUtilisateur(utilisateur.Id);

            if (Ut == null)
            {
                return(View("Error"));
            }
            //votes.Utilisateur = Ut;
            //votes.Restos = restos;
            //var Co = votes.CreerVotes().Count;
            //var Restos = dal.ObtientTousLesRestaurants();
            var Mod = new Votes();

            //var SonId = Request.Form["IdSondage"];
            if (!idSondage.HasValue)
            {
                return(View("Error"));
            }
            int IdSon = idSondage.Value;

            /*if (!int.TryParse(SonId, out IdSon))
             * {
             *  return View("Error");
             * }*/
            if (!dal.ADejaVoteBis(IdSon, Ut.Id.ToString()))
            {
                bool Voted    = false;
                var  Index    = 0;
                var  RestList = dal.ObtientTousLesRestaurants();

                /*foreach (var r in votes.CreerVotes())
                 * {
                 *  var Sel = Request.Form["Restos[" + Index + "].EstSelectionne"];
                 *  var Ind = Request.Form["Restos[" + Index + "].Id"];
                 *  var RestoResult = RestList.FirstOrDefault(Rest => Rest.Id.ToString() == Ind);
                 *  if (RestoResult == null)
                 *  {
                 *      Index++;
                 *      continue;
                 *  }
                 *  if (Sel == "false")
                 *  {
                 *      Index++;
                 *      continue;
                 *  }
                 *  Voted = true;
                 *  dal.AjouterVote(IdSon, RestoResult.Id, Ut.Id);
                 *  Index++;
                 * }*/
                foreach (var r in restos)
                {
                    var Sel = r.EstSelectionne;
                    //r.NomEtTelephone == null
                    var Ind         = r.Id;
                    var RestoResult = RestList.FirstOrDefault(Rest => Rest.Id == Ind);
                    if (RestoResult == null)
                    {
                        Index++;
                        continue;
                    }
                    if (!Sel)
                    {
                        Index++;
                        continue;
                    }
                    Voted = true;
                    dal.AjouterVote(IdSon, RestoResult.Id, Ut.Id);
                    Index++;
                }
                if (!Voted)
                {
                    Votes vo = new Votes();
                    vo.IdSondage   = IdSon;
                    vo.Utilisateur = Ut;
                    var Restos = dal.ObtientTousLesRestaurants();
                    vo.Restos = new List <RestaurantCheckBoxViewModel>();
                    foreach (var r in Restos)
                    {
                        var res = new RestaurantCheckBoxViewModel();
                        res.Rest           = r;
                        res.NomEtTelephone = r.Nom + " " + r.Telephone;
                        res.Id             = r.Id;
                        vo.Restos.Add(res);
                    }
                    vo.Error = true;
                    return(View("~/Views/Vote/Index.cshtml", vo));
                }
            }

            /*StringBuilder Str = new StringBuilder();
             * Str.Append(IdSon).Append(",");*/
            //var Index = 0;
            //var RestList = dal.ObtientTousLesRestaurants();

            /*foreach (var r in votes.CreerVotes())
             * {
             *  var Sel = Request.Form["Restos[" + Index + "].EstSelectionne"];
             *  var Ind = Request.Form["Restos[" + Index + "].Id"];
             *  //
             *  Str.Append(Sel).Append(",");
             *  Str.Append(Ind).Append(",");
             *  var RestoResult = RestList.FirstOrDefault(Rest => Rest.Id.ToString() == Ind);
             *  if (RestoResult == null)
             *  {
             *      Index++;
             *      continue;
             *  }
             *  Str.Append(RestoResult.Nom).Append(",");
             *
             *  if (Ut != null) {
             *      Str.Append(Ut.Prenom).Append("\n");
             *      dal.AjouterVote(IdSon, RestoResult.Id, Ut.Id);
             *  } else
             *  {
             *      Str.Append(Ut).Append("\n");
             *  }
             *  Index++;
             *
             * }*/
            var          welcome             = new WelcomeForm();
            var          welcome2            = new Welcome();
            List <Resto> listeDesRestaurants = dal.ObtientTousLesRestaurants();

            welcome2.Bdd      = listeDesRestaurants;
            welcome2.Sondages = dal.ObtenirSondages();
            welcome.welcome   = welcome2;
            welcome.sel       = new SelectList(welcome2.Sondages, "Id", "Id");
            //return File(Encoding.ASCII.GetBytes(Str.ToString()), "application/octet-stream", "MonFichier.txt");
            return(View("~/Views/Restaurant/Index.cshtml", welcome));
            //return View(Mod);
        }