Exemplo n.º 1
0
        private Discount SaveDiscount(FIL.Contracts.Models.CreateEventV1.DiscountModel discountModel)
        {
            var EventTicketDisocuntDetail = _eventTicketDiscountDetailRepository.GetByETAId(discountModel.EventTicketAttributeId);
            var discountDataModel         = new Discount()
            {
                Id                            = EventTicketDisocuntDetail != null ? EventTicketDisocuntDetail.DiscountId : 0,
                DiscountTypeId                = discountModel.DiscountTypes,
                DiscountValueTypeId           = discountModel.DiscountValueType,
                DiscountValue                 = discountModel.DiscountValueType == Contracts.Enums.DiscountValueType.Flat ? discountModel.DiscountAmount : discountModel.DiscountPercentage,
                MaximumDiscountPerTransaction = 0,
                OverallMaximumDiscount        = 0,
                MinimumQuantityPerTransaction = 0,
                MaximumQuantityPerTransaction = 0,
                Name                          = discountModel.EventName,
                IsEnabled                     = discountModel.IsEnabled,
                OverallMaximumQuantity        = 0,
                CreatedBy                     = EventTicketDisocuntDetail != null ? EventTicketDisocuntDetail.CreatedBy : discountModel.ModifiedBy,
                CreatedUtc                    = EventTicketDisocuntDetail != null ? EventTicketDisocuntDetail.CreatedUtc : DateTime.UtcNow,
                Description                   = "",
                ModifiedBy                    = discountModel.ModifiedBy,
                UpdatedBy                     = discountModel.ModifiedBy,
                UpdatedUtc                    = DateTime.UtcNow
            };

            return(_discountRepository.Save(discountDataModel));
        }
Exemplo n.º 2
0
 public EventTicketDiscountDetail SaveEventDiscount(FIL.Contracts.Models.CreateEventV1.DiscountModel discountModel)
 {
     try
     {
         var discount                  = SaveDiscount(discountModel);
         var discountPromoCode         = SaveDiscountPromoCode(discountModel, discount.Id);
         var eventTicketDiscountDetail = SaveEventTicketDiscount(discountModel, discount.Id);
         return(eventTicketDiscountDetail);
     }
     catch (Exception e)
     {
         _logger.Log(FIL.Logging.Enums.LogCategory.Error, e);
         return(new EventTicketDiscountDetail {
         });
     }
 }
Exemplo n.º 3
0
        private DiscountPromoCode SaveDiscountPromoCode(FIL.Contracts.Models.CreateEventV1.DiscountModel discountModel, int discountId)
        {
            var discountPromoCode          = _discountPromoCodeRepository.Get(discountId);
            var discountPromoCodeDataModel = new FIL.Contracts.DataModels.DiscountPromoCode()
            {
                Id                = discountPromoCode != null ? discountPromoCode.Id : 0,
                DiscountId        = discountId,
                PromoCode         = discountModel.PromoCode,
                PromoCodeStatusId = Contracts.Enums.PromoCodeStatus.Available,
                IsEnabled         = discountModel.IsEnabled,
                CreatedBy         = discountPromoCode != null ? discountPromoCode.CreatedBy : discountModel.ModifiedBy,
                CreatedUtc        = discountPromoCode != null ? discountPromoCode.CreatedUtc : DateTime.UtcNow,
                ModifiedBy        = discountModel.ModifiedBy,
                UpdatedBy         = discountModel.ModifiedBy,
                UpdatedUtc        = DateTime.UtcNow
            };

            return(_discountPromoCodeRepository.Save(discountPromoCodeDataModel));
        }
Exemplo n.º 4
0
        private EventTicketDiscountDetail SaveEventTicketDiscount(FIL.Contracts.Models.CreateEventV1.DiscountModel discountModel, int discountId)
        {
            var eventTicketDiscountDetail  = _eventTicketDiscountDetailRepository.GetByEventTicketAttributeId((int)discountModel.EventTicketAttributeId);
            var eventTicketDiscountDetail1 = new FIL.Contracts.DataModels.EventTicketDiscountDetail()
            {
                Id                     = eventTicketDiscountDetail != null ? eventTicketDiscountDetail.Id : 0,
                DiscountId             = discountId,
                StartDateTime          = DateTime.UtcNow,
                EventTicketAttributeId = discountModel.EventTicketAttributeId,
                EndDateTime            = DateTime.UtcNow,
                IsEnabled              = discountModel.IsEnabled,
                CreatedBy              = eventTicketDiscountDetail != null ? eventTicketDiscountDetail.CreatedBy : discountModel.ModifiedBy,
                CreatedUtc             = eventTicketDiscountDetail != null ? eventTicketDiscountDetail.CreatedUtc : DateTime.UtcNow,
                ModifiedBy             = discountModel.ModifiedBy,
                UpdatedBy              = discountModel.ModifiedBy,
                UpdatedUtc             = DateTime.UtcNow
            };

            return(_eventTicketDiscountDetailRepository.Save(eventTicketDiscountDetail1));
        }
Exemplo n.º 5
0
        private void SaveTicketDiscount(CreateTicketCommand command,
                                        long eventTicketAttributeId,
                                        string EventName)
        {
            if (String.IsNullOrEmpty(command.Tickets.FirstOrDefault().PromoCode))
            {
                return;
            }
            var discountCustomModel = new FIL.Contracts.Models.CreateEventV1.DiscountModel
            {
                DiscountAmount         = command.Tickets.FirstOrDefault().DiscountAmount,
                EventTicketAttributeId = eventTicketAttributeId,
                DiscountPercentage     = command.Tickets.FirstOrDefault().DiscountPercentage,
                DiscountValueType      = command.Tickets.FirstOrDefault().DiscountValueType,
                DiscountTypes          = FIL.Contracts.Enums.DiscountTypes.PromoCodeBased,
                EventName  = EventName,
                IsEnabled  = command.Tickets.FirstOrDefault().IsDiscountEnable,
                ModifiedBy = command.ModifiedBy,
                PromoCode  = command.Tickets.FirstOrDefault().PromoCode
            };

            _discountProvider.SaveEventDiscount(discountCustomModel);
        }