public ServiceResult CancelRegistration(int existingRegistrationId)
        {
            var result = new ServiceResult();
            IEmailService emailService = new EmailService();
            IDiscountService discountService = new DiscountService(this._repository, false);

            Registration cancelReg = _repository.Registrations.Find(x => x.RegistrationId == existingRegistrationId);
            cancelReg.RegistrationStatus = RegistrationStatus.Cancelled;
            cancelReg.DateUpdated = DateTime.Now;

            var newTransferCode = new RedemptionCode
            {
                GeneratingRegistrationId = existingRegistrationId,
                Code = discountService.GenerateDiscountCode(),
                RedemptionCodeType = RedemptionCodeType.StraightValue,
                Value = GetRegistrationPathValue(existingRegistrationId),
                DiscountType = DiscountType.Dollars
            };

            result = discountService.CreateRedemptionCode(newTransferCode);

            if (!_sharedRepository)
            {
                _repository.SaveChanges();
                emailService.SendCancellationEmail(newTransferCode.DiscountItemId);
            }

            return result;
        }
        public ServiceResult CreateRedemptionCode(RedemptionCode redemptionCode)
        {
            var result = new ServiceResult();

            try
            {
                _repository.RedemptionCodes.Create(redemptionCode);

                if (!_sharedRepository)
                    _repository.SaveChanges();

            }
            catch (Exception ex)
            {
                result.AddServiceError(Utilities.GetInnerMostException(ex));
            }

            return result;
        }
        public ServiceResult TransferRegistration(int existingRegistrationId, string name, string email)
        {
            ServiceResult result = null;

            IEmailService emailService = new EmailService();
            var discountService = new DiscountService(this._repository, false);

            Registration transferReg = _repository.Registrations.Find(x => x.RegistrationId == existingRegistrationId);
            transferReg.RegistrationStatus = RegistrationStatus.Held;
            transferReg.DateUpdated = DateTime.Now;

            var newTransferCode = new RedemptionCode
            {
                GeneratingRegistrationId = existingRegistrationId,
                Code = discountService.GenerateDiscountCode(),
                RedemptionCodeType = RedemptionCodeType.Transfer,
                Value = GetRegistrationPathValue(existingRegistrationId),
                DiscountType = DiscountType.Dollars
            };

            result = discountService.CreateRedemptionCode(newTransferCode);

            if (!_sharedRepository)
            {
                _repository.SaveChanges();
                emailService.SendTransferEmail(newTransferCode.DiscountItemId, name, email);
            }

            return result;
        }
Exemple #4
0
        private bool NeedToRemoveProcessingFee(SessionCart currentCart, RedemptionCode code)
        {
            if (!NeedToRemoveProcessingFee(currentCart))            // check base method
                return false;

            if (code.RedemptionCodeType == RedemptionCodeType.StraightValue ||      // check out redemption type
                code.RedemptionCodeType == RedemptionCodeType.Transfer)
                return true;

            return false;                                           // no good reason to remove it...
        }