Ejemplo n.º 1
0
        public ActionResult Create(int id, DateTime ArrivalDate, DateTime DepartureDate)
        {
            CreateReservationVm model = new CreateReservationVm();

            model.RoomType   = _mapper.Map <RoomTypeVm>(_roomTypeCrudService.Get(id));
            model.TotalPrice = (DepartureDate - ArrivalDate).Days * model.RoomType.Price;
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Create(CreateReservationVm model)
        {
            if (!ModelState.IsValid && model.TotalPrice != 0M)
            {
                model.RoomType = _mapper.Map <RoomTypeVm>(_roomTypeCrudService.Get(model.RoomType.Id));
                return(View(model));
            }

            ReservationDto reservation = _mapper.Map <ReservationDto>(model);

            reservation.ClientId = this.HttpContext.User.Identity.GetUserId();
            _reservationService.Create(reservation);
            return(RedirectToAction("Index", "Home"));
        }