Exemplo n.º 1
0
 public ActionResult Create(int id, int numberOfPersons, DateTime date)
 {
     var rest = _reservationService.GetRestaurant(id);
     var createModel = new CreateReservationModel();
     createModel.TimeSlot = date;
     createModel.RestaurantId = rest.Id;
     createModel.RestaurantName = rest.Name;
     createModel.Email = "";
     createModel.AvailableTimes = _reservationService.GetAvailableTimes(rest.Id, numberOfPersons, date);
     createModel.TimeSelectList = new SelectList(createModel.AvailableTimes.Where(x => x.FreeSeats), "Hour", "Hour");
     createModel.PersonCount = numberOfPersons;
     createModel.Date = date;
     createModel.Name = "";
     return View(createModel);
 }
Exemplo n.º 2
0
        public ActionResult Create(CreateReservationModel model)
        {
            if (ModelState.IsValid)
            {
                Reservation r = new Reservation();
                r.Name = model.Name;
                r.Email = model.Email;
                r.Telephone = model.Telephone;
                r.PersonCount = model.PersonCount;
                r.Restaurant = _reservationService.GetRestaurant(model.RestaurantId);
                r.TimeSlot = model.Date.AddHours(model.Time);

                int reservationId = _reservationService.SaveReservation(r).Id;

                return RedirectToAction("Details", "Reservation", new { id = reservationId});

            }
            return View(model);
        }