Beispiel #1
0
        public ActionResult Index(RestaurantVoteViewModel viewModel, int id)
        {
            if (!ModelState.IsValid)
                return View(viewModel);

            Utilisateur utilisateur = dal.ObtenirUtilisateur(Request.Browser.Browser);
            if (utilisateur == null)
                return new HttpUnauthorizedResult();

            foreach (RestaurantCheckBoxViewModel restaurantCheckBoxViewModel in
                viewModel.ListeDesRestos.Where(r => r.EstSelectionne))
            {
                dal.AjouterVote(id, restaurantCheckBoxViewModel.Id, utilisateur.Id);
            }
            return RedirectToAction("AfficheResultat", new { id = id });
        }
Beispiel #2
0
        public ActionResult Index(int id)
        {
            RestaurantVoteViewModel viewModel = new RestaurantVoteViewModel
            {
                ListeDesRestos = dal.ObtientTousLesRestaurants().Select(r=>
                    new RestaurantCheckBoxViewModel { Id=r.Id, NomEtTelephone = string.Format("{0} ({1})",
                        r.Nom,r.Telephone)}).ToList()
            };

            if (dal.ADejaVote(id, Request.Browser.Browser))
            {
                return RedirectToAction("AfficheResultat", new { id = id });
            }

            return View(viewModel);
        }