Пример #1
0
        public ActionResult Cancelled(BookingCommandBase command)
        {
            var handler = new BookingCommandHandler(_context);

            handler.Cancelled(command);

            return(RedirectToAction("BookingsOnProperty", new { id = command.PropertyId }));
        }
Пример #2
0
 public bool AddAction(BookingCommandBase activity)
 {
     using (IDbConnection connection = OpenConnection())
     {
         return 1 == connection.Execute(
             string.Format(@"INSERT INTO `booking_activities` ({0}) VALUES ({1});",
             SqlHelper.Columns(_activityColumns),
             SqlHelper.Params(_activityColumns)),
             BookingActivityPM.ToPM(activity));
     }
 }
Пример #3
0
        public void EnsoureAndUpdateState(BookingCommandBase action)
        {
            var command = (BookingCommand)Enum.Parse(typeof(BookingCommand), action.GetType().Name, true);

            var instance = _stateMachine.Instance(this.State);
            if (!instance.Fire(command))
            {
                throw new BusinessException(BusinessStatusCode.Forbidden, "Invalid booking state.");
            }
            this.State = instance.State;
        }
Пример #4
0
 public static BookingActivityPM ToPM(BookingCommandBase action)
 {
     BookingActivityPM pm = Mapper.Map<BookingActivityPM>(action);
     if (pm.TimeSlot != null)
     {
         pm.From = pm.TimeSlot.From;
         pm.To = pm.TimeSlot.To;
         pm.Minutes = pm.TimeSlot.Minutes;
     }
     pm.Type = (BookingCommand)Enum.Parse(typeof(BookingCommand), action.GetType().Name, true);
     return pm;
 }