Exemplo n.º 1
0
        public IActionResult ReservationToEvent(int idEvent)
        {
            var newResa = new ReserveEventViewModel
            {
                IdEvent   = idEvent,
                IdUser    = UserService.GetUserByMail(User.Identity.Name).Id,
                NomEvent  = EventServices.GetEvent(idEvent).Nom,
                PlacLibre = EventServices.GetEvent(idEvent).Place - Liaison.GetAllLiaison().Where(w => w.EventId == idEvent).Count(),
            };

            return(View(newResa));
        }
Exemplo n.º 2
0
        public IActionResult ReservationToEvent(ReserveEventViewModel reserveEvent)
        {
            var place = EventServices.GetEvent(reserveEvent.IdEvent).Place - Liaison.GetAllLiaison().Where(w => w.EventId == reserveEvent.IdEvent).Count();

            if (place - reserveEvent.PlacePrise > 0)
            {
                for (int i = 0; i < reserveEvent.PlacePrise; i++)
                {
                    Liaison.CreateLiaison(reserveEvent.IdEvent, reserveEvent.IdUser);
                }
                return(RedirectToAction(nameof(Index)));
            }
            ModelState.AddModelError("File", "Il n'y pas assez de place disponible");
            reserveEvent.NomEvent = EventServices.GetEvent(reserveEvent.IdEvent).Nom;
            return(View(reserveEvent));
        }