Beispiel #1
0
        public Promotion(Guid id, string name, string description, DateTime?startDate, DateTime?endDate, DateTime?startTime,
                         DateTime?endTime, DayOfWeek[] daysOfWeek, bool appliesToCurrentBooking, bool appliesToFutureBooking,
                         decimal discountValue, PromoDiscountType discountType, int?maxUsagePerUser, int?maxUsage, string code,
                         DateTime?publishedStartDate, DateTime?publishedEndDate, PromotionTriggerSettings triggerSettings)
            : this(id)
        {
            if (Params.Get(name, code).Any(p => p.IsNullOrEmpty()))
            {
                throw new InvalidOperationException("Missing required fields");
            }

            Update(new PromotionCreated
            {
                Name                    = name,
                Description             = description,
                StartDate               = startDate,
                EndDate                 = endDate,
                StartTime               = startTime,
                EndTime                 = endTime,
                DaysOfWeek              = daysOfWeek,
                AppliesToCurrentBooking = appliesToCurrentBooking,
                AppliesToFutureBooking  = appliesToFutureBooking,
                DiscountValue           = discountValue,
                DiscountType            = discountType,
                MaxUsagePerUser         = maxUsagePerUser,
                MaxUsage                = maxUsage,
                Code                    = code,
                PublishedStartDate      = publishedStartDate,
                PublishedEndDate        = publishedEndDate,
                TriggerSettings         = triggerSettings ?? new PromotionTriggerSettings()
            });
        }
Beispiel #2
0
        private void OnPromotionUpdated(PromotionUpdated @event)
        {
            _startDate  = @event.StartDate;
            _endDate    = @event.EndDate;
            _daysOfWeek = @event.DaysOfWeek;
            _appliesToCurrentBooking = @event.AppliesToCurrentBooking;
            _appliesToFutureBooking  = @event.AppliesToFutureBooking;
            _maxUsagesPerUser        = @event.MaxUsagePerUser;
            _maxUsages       = @event.MaxUsage;
            _discountValue   = @event.DiscountValue;
            _discountType    = @event.DiscountType;
            _code            = @event.Code;
            _triggerSettings = @event.TriggerSettings;

            SetInternalStartAndEndTimes(@event.StartTime, @event.EndTime);
        }