Exemplo n.º 1
0
        public ActionResult CheckOut(Guid id)
        {
            if (ModelState.IsValid)
            {
                CheckOutBooking cmd = new CheckOutBooking
                {
                    Id             = id,
                    CheckedOutDate = DateTime.Now
                };

                Domain.Dispatcher.SendCommand(cmd);
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public IActionResult CheckOutBooking(CheckOutBooking checkOutBooking)
 {
     if (ModelState.IsValid)
     {
         try
         {
             checkOutBooking.Id = checkOutBooking.BookingId;
             _domain.Dispatcher.SendCommand(checkOutBooking);
             return(RedirectToAction("BookingCheckOut", new { result = true, inProcess = true, errorMessage = "" }));
         }
         catch (Exception e)
         {
             _logger.LogInformation(ExceptionTranslator.TranslateException(e));
             return(RedirectToAction("BookingCheckOut", new { result = false, inProcess = true, errorMessage = ExceptionTranslator.TranslateException(e) }));
         }
     }
     return(RedirectToAction("BookingCheckOut", new { result = false, inProcess = true, errorMessage = "Invalid data" }));
 }
        public IEnumerable Handle(CheckOutBooking c)
        {
            if (!DoesBookingExist(c.BookingId))
            {
                throw new UnexistingBooking();
            }
            else if ((from booking in bookingsCheckedOut
                      where booking.BookingId == c.BookingId
                      select booking).Count() == 1)
            {
                throw new CanNotCheckOutTwice();
            }

            yield return(new BookingCheckedOut()
            {
                Id = c.Id,
                BookingId = c.BookingId,
                CheckOutDate = c.CheckOutDate
            });
        }