コード例 #1
0
        public Subscription CreateSubscription(SubscriptionPlan plan, string paymentMethodToken, DateTimeOffset trialEndDate)
        {
            var descriptor = new DescriptorRequest
            {
                Name = GetSubscriptionPlanDescriptor(plan)
            };

            var now               = DateTimeOffset.Now;
            var trialDuration     = now > trialEndDate ? TimeSpan.Zero : trialEndDate - now;
            var trialDurationDays = trialDuration > TimeSpan.Zero ? (int)Math.Floor(trialDuration.TotalDays) : 0;

            var request = new SubscriptionRequest
            {
                PaymentMethodToken = paymentMethodToken,
                PlanId             = plan.ToString(),
                Descriptor         = descriptor,
                TrialDuration      = trialDurationDays,
                TrialDurationUnit  = SubscriptionDurationUnit.DAY,
                HasTrialPeriod     = trialDurationDays > 0
            };

            var result = Gateway.Subscription.Create(request);

            if (result.IsSuccess())
            {
                return(result.Target);
            }
            else
            {
                throw new Exception(result.Message);
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns the correct descriptor name for the given plan,
        /// following gateway naming restrictions.
        /// </summary>
        /// <param name="plan"></param>
        /// <returns></returns>
        public string GetSubscriptionPlanDescriptor(SubscriptionPlan plan)
        {
            // IMPORTANT: Braintree restricts the naming possibilities
            // as described at https://developers.braintreepayments.com/reference/request/transaction/sale/dotnet#descriptor.name
            // Copied: Company name/DBA section must be either 3, 7 or 12 characters
            // and the product descriptor can be up to 18, 14, or 9 characters respectively (with an * in between
            // for a total descriptor name of 22 characters)
            // NOTE: We choose 12 chars for 'Loconomics  ' (double white space in the end
            // to match twelve) plus short plan name ('ProAnnual' fits exactly, 9)
            switch (plan)
            {
            case SubscriptionPlan.Free:
                throw new ArgumentException("A free plan don't need a paid subscription");

            case SubscriptionPlan.OwnerProAnnual:
                return("Loconomics  *ProAnnual");

            case SubscriptionPlan.OwnerPro:
                return("Loconomics  *Pro");

            case SubscriptionPlan.OwnerGrowth:
                return("Loconomics  *Growth");

            default:
                throw new ArgumentException("Plan value unsupported");
            }
        }
コード例 #3
0
 internal SubscriberBase(
     List <KeyValuePair <string, string> > badges,
     List <KeyValuePair <string, string> > badgeInfo,
     string colorHex,
     Color color,
     string displayName,
     string emoteSet,
     string id,
     string login,
     string systemMessage,
     string msgId,
     string msgParamCumulativeMonths,
     string msgParamStreakMonths,
     bool msgParamShouldShareStreak,
     string systemMessageParsed,
     string resubMessage,
     SubscriptionPlan subscriptionPlan,
     string subscriptionPlanName,
     string roomId,
     string userId,
     bool isModerator,
     bool isTurbo,
     bool isSubscriber,
     bool isPartner,
     string tmiSentTs,
     UserType userType,
     string rawIrc,
     string channel,
     int months)
 {
     Badges      = badges;
     BadgeInfo   = badgeInfo;
     ColorHex    = colorHex;
     Color       = color;
     DisplayName = displayName;
     EmoteSet    = emoteSet;
     Id          = id;
     Login       = login;
     MsgId       = msgId;
     MsgParamCumulativeMonths  = msgParamCumulativeMonths;
     MsgParamStreakMonths      = msgParamStreakMonths;
     MsgParamShouldShareStreak = msgParamShouldShareStreak;
     SystemMessage             = systemMessage;
     SystemMessageParsed       = systemMessageParsed;
     ResubMessage         = resubMessage;
     SubscriptionPlan     = subscriptionPlan;
     SubscriptionPlanName = subscriptionPlanName;
     RoomId         = roomId;
     UserId         = UserId;
     IsModerator    = isModerator;
     IsTurbo        = isTurbo;
     IsSubscriber   = isSubscriber;
     IsPartner      = isPartner;
     TmiSentTs      = tmiSentTs;
     UserType       = userType;
     RawIrc         = rawIrc;
     monthsInternal = months;
     UserId         = userId;
     Channel        = channel;
 }
コード例 #4
0
        public async Task <List <SubscriptionPlan> > GetAll()
        {
            var products = await productService.ListAsync();

            var plans = new List <SubscriptionPlan>();

            for (int i = 0; i < products.Count(); i++)
            {
                var product = products.ElementAt(i);

                // Check to see if we've given it an ID yet.
                if (!product.Metadata.ContainsKey("Id"))
                {
                    var updateOpts = new ProductUpdateOptions();
                    updateOpts.Metadata       = new Dictionary <string, string>();
                    updateOpts.Metadata["Id"] = Guid.NewGuid().ToString();

                    product = await productService.UpdateAsync(product.Id, updateOpts);
                }

                var plan = new SubscriptionPlan(
                    Guid.Parse(product.Metadata["Id"]),
                    product.Name,
                    product.Description,
                    BillingReference.Product(product.Id),
                    await GetPrices(product.Id)
                    );

                plans.Add(plan);
            }

            return(plans);
        }
コード例 #5
0
        protected int CountExpiringSubscriptions(Object dataItem, int expDays)
        {
            SubscriptionPlan subscriptionPlan = (SubscriptionPlan)dataItem;
            DateTime         expDateEnd       = GetEndOfDay(LocaleHelper.LocalNow.AddDays(expDays));

            return(SubscriptionDataSource.SearchCount(subscriptionPlan.Product.Id, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, DateTime.MinValue, expDateEnd, BitFieldState.Any));
        }
コード例 #6
0
        public async Task Delete(SubscriptionPlan entity)
        {
            using (var conn = OpenConnection()) {
                using (var t = conn.BeginTransaction()) {
                    await conn.ExecuteAsync(
                        @"delete from subscription_plan_prices where plan_id = @Id;",
                        entity,
                        t
                        );

                    await conn.ExecuteAsync(
                        @"delete from subscription_plans where id = @Id;",
                        entity,
                        t
                        );

                    await conn.ExecuteAsync(
                        @"delete from billing_references where billing_id = @BillingId;",
                        entity.BillingReference,
                        t
                        );

                    await conn.ExecuteAsync(
                        @"delete from billing_references where billing_id = @BillingId;",
                        entity.Prices.Select(p => p.BillingReference).ToList(),
                        t
                        );

                    t.Commit();
                }
            }
        }
コード例 #7
0
ファイル: Configuration.cs プロジェクト: twocngdagz/AngJobs
        private static void AddSubscriptionPlan(Angjobs.Models.DBContext context)
        {
            string paymentSystemId = "Up100PerMo";

            if (context.SubscriptionPlans.FirstOrDefault(p => p.PaymentSystemId == paymentSystemId) == null)
            {
                var plan = new SubscriptionPlan();
                plan.Description     = "Up to 100 job applications - monthly plan";
                plan.PaymentSystemId = paymentSystemId;
                plan.Price           = 3.99f;
                plan.Currency        = "gbp";
                plan.State           = SubscriptionPlan.SubscriptionState.Available;
                plan.Title           = "Up to 100 job applications per month";
                plan.CreatedDateUtc  = DateTime.UtcNow;
                plan.IsSoftDeleted   = false;

                context.SubscriptionPlans.Add(plan);

                try
                {
                    StripeManager.CreatePlan(plan);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Error:", ex.Message);
                }
            }
        }
コード例 #8
0
        public async Task <IActionResult> Edit(int id, SubscriptionPlan entity, int durationInDays = default)
        {
            if (id != entity.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (durationInDays != default)
                    {
                        entity.Duration = TimeSpan.FromDays(durationInDays);
                    }
                    _context.Update(entity);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EntityExists(entity.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                return(RedirectToAction(nameof(Index).ToString()));
            }

            return(View(entity));
        }
コード例 #9
0
 public GiftedSubscription(string badges, string color, string displayName, string emotes, string id, string login, bool isModerator,
                           string msgId, string msgParamMonths, string msgParamRecipientDisplayName, string msgParamRecipientId, string msgParamRecipientUserName,
                           string msgParamSubPlanName, SubscriptionPlan msgParamSubPlan, string roomId, bool isSubscriber, string systemMsg, string systemMsgParsed,
                           string tmiSentTs, bool isTurbo, UserType userType)
 {
     Badges         = badges;
     Color          = color;
     DisplayName    = displayName;
     Emotes         = emotes;
     Id             = id;
     Login          = login;
     IsModerator    = isModerator;
     MsgId          = msgId;
     MsgParamMonths = msgParamMonths;
     MsgParamRecipientDisplayName = msgParamRecipientDisplayName;
     MsgParamRecipientId          = msgParamRecipientId;
     MsgParamRecipientUserName    = msgParamRecipientUserName;
     MsgParamSubPlanName          = msgParamSubPlanName;
     MsgParamSubPlan = msgParamSubPlan;
     RoomId          = roomId;
     IsSubscriber    = isSubscriber;
     SystemMsg       = systemMsg;
     SystemMsgParsed = systemMsgParsed;
     TmiSentTs       = tmiSentTs;
     IsTurbo         = isTurbo;
     UserType        = userType;
 }
コード例 #10
0
 internal SubscriberBase(List <KeyValuePair <string, string> > badges, string colorHex, Color color, string displayName, string emoteSet, string id, string login, string systemMessage,
                         string systemMessageParsed, string resubMessage, SubscriptionPlan subscriptionPlan, string subscriptionPlanName, string roomId, string userId, bool isModerator, bool isTurbo,
                         bool isSubscriber, bool isPartner, string tmiSentTs, UserType userType, string rawIrc, string channel)
 {
     Badges               = badges;
     ColorHex             = colorHex;
     Color                = color;
     DisplayName          = displayName;
     EmoteSet             = emoteSet;
     Id                   = id;
     Login                = login;
     SystemMessage        = systemMessage;
     SystemMessageParsed  = systemMessageParsed;
     ResubMessage         = resubMessage;
     SubscriptionPlan     = subscriptionPlan;
     SubscriptionPlanName = subscriptionPlanName;
     RoomId               = roomId;
     UserId               = UserId;
     IsModerator          = isModerator;
     IsTurbo              = isTurbo;
     IsSubscriber         = isSubscriber;
     IsPartner            = isPartner;
     TmiSentTs            = tmiSentTs;
     UserType             = userType;
     RawIrc               = rawIrc;
 }
コード例 #11
0
        public int Create(Format_Create parseData)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                SubscriptionPlan newData = new SubscriptionPlan();
                newData.Name        = parseData.Name;
                newData.Description = parseData.Description ?? "";
                newData.DefaultRatePer1KMessageIngestion = parseData.DefaultRatePer1KMessageIngestion ?? 0;
                newData.DefaultRatePer1KMessageHotStore  = parseData.DefaultRatePer1KMessageHotStore ?? 0;
                newData.DefaultRatePer1KMessageColdStore = parseData.DefaultRatePer1KMessageColdStore ?? 0;
                newData.DefaultPlanDays = parseData.DefaultPlanDays;
                newData.DefaultMaxMessageQuotaPerDay    = parseData.DefaultMaxMessageQuotaPerDay;
                newData.DefaultStoreHotMessage          = parseData.DefaultStoreHotMessage ?? false;
                newData.DefaultStoreColdMessage         = parseData.DefaultStoreColdMessage ?? false;
                newData.DefaultCosmosDBConnectionString = parseData.DefaultCosmosDBConnectionString ?? "";
                newData.DefaultCollectionTTL            = parseData.DefaultCollectionTTL ?? 86400;
                newData.DefaultCollectionReservedUnits  = parseData.DefaultCollectionReservedUnits ?? 400;
                newData.DefaultIoTHubConnectionString   = parseData.DefaultIoTHubConnectionString ?? "";
                newData.DefaultStorageConnectionString  = parseData.DefaultStorageConnectionString ?? "";

                dbEntity.SubscriptionPlan.Add(newData);
                dbEntity.SaveChanges();
                return(newData.Id);
            }
        }
コード例 #12
0
        public Format_Detail GetById(int id)
        {
            using (CDStudioEntities dbEntity = new CDStudioEntities())
            {
                SubscriptionPlan existingData = (from c in dbEntity.SubscriptionPlan.AsNoTracking()
                                                 where c.Id == id
                                                 select c).SingleOrDefault <SubscriptionPlan>();
                if (existingData == null)
                {
                    throw new CDSException(10701);
                }

                return(new Format_Detail()
                {
                    Id = existingData.Id,
                    Name = existingData.Name,
                    Description = existingData.Description,
                    DefaultRatePer1KMessageIngestion = (double)existingData.DefaultRatePer1KMessageIngestion,
                    DefaultRatePer1KMessageHotStore = (double)existingData.DefaultRatePer1KMessageHotStore,
                    DefaultRatePer1KMessageColdStore = (double)existingData.DefaultRatePer1KMessageColdStore,
                    DefaultPlanDays = existingData.DefaultPlanDays,
                    DefaultMaxMessageQuotaPerDay = existingData.DefaultMaxMessageQuotaPerDay,
                    DefaultStoreHotMessage = (bool)existingData.DefaultStoreHotMessage,
                    DefaultStoreColdMessage = (bool)existingData.DefaultStoreColdMessage,
                    DefaultCosmosDBConnectionString = existingData.DefaultCosmosDBConnectionString,
                    DefaultCollectionTTL = (int)existingData.DefaultCollectionTTL,
                    DefaultCollectionReservedUnits = (int)existingData.DefaultCollectionReservedUnits,
                    DefaultIoTHubConnectionString = existingData.DefaultIoTHubConnectionString,
                    DefaultStorageConnectionString = existingData.DefaultStorageConnectionString
                });
            }
        }
        public async Task <SubscriptionPlanResponse> UpdateAsync(int id, SubscriptionPlan subscriptionPlan)
        {
            var existingSubscriptionPlan = await _subscriptionPlanRepository.FindById(id);

            if (existingSubscriptionPlan == null)
            {
                return(new SubscriptionPlanResponse("subscription plan not found"));
            }


            existingSubscriptionPlan.Name        = subscriptionPlan.Name;
            existingSubscriptionPlan.Description = subscriptionPlan.Description;
            existingSubscriptionPlan.Cost        = subscriptionPlan.Cost;

            try
            {
                _subscriptionPlanRepository.Update(existingSubscriptionPlan);
                await _unitOfWork.CompleteAsync();

                return(new SubscriptionPlanResponse(existingSubscriptionPlan));
            }
            catch (Exception ex)
            {
                return(new SubscriptionPlanResponse($"An error ocurred while updating subscription Plan: {ex.Message}"));
            }
        }
コード例 #14
0
        public ActionResult AddSubscriptionPlan(SiteSubscriptionPlansViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                // Create an Auto Mapper map between the subscription plan entity and the view model. Ignore the id as this will be auto-generated.
                Mapper.CreateMap <SiteSubscriptionPlansViewModel, SubscriptionPlan>().ForMember(x => x.SubscriptionPlanId, opt => opt.Ignore());

                // Populate a subscription plan with automapper and pass it back to the service layer for addition.
                SubscriptionPlan  subscriptionPlan = Mapper.Map <SiteSubscriptionPlansViewModel, SubscriptionPlan>(viewModel);
                IValidationResult validationResult = this.doctrineShipsServices.AddSubscriptionPlan(subscriptionPlan);

                // If the validationResult is not valid, something did not validate in the service layer.
                if (validationResult.IsValid)
                {
                    TempData["Status"] = "The subscription plan was successfully added.";
                }
                else
                {
                    TempData["Status"] = "Error: The subscription plan was not added, a validation error occured.<br /><b>Error Details: </b>";

                    foreach (var error in validationResult.Errors)
                    {
                        TempData["Status"] += error.Value + "<br />";
                    }
                }

                return(RedirectToAction("SubscriptionPlans"));
            }
            else
            {
                // Re-populate the view model and return with any validation errors.
                viewModel.SubscriptionPlans = this.doctrineShipsServices.GetSubscriptionPlans();
                return(View("~/Views/Site/SubscriptionPlans.cshtml", viewModel));
            }
        }
コード例 #15
0
        internal IValidationResult SubscriptionPlan(SubscriptionPlan subscriptionPlan)
        {
            IValidationResult validationResult = new ValidationResult();

            // Null checks.
            if (subscriptionPlan.Name == null)
            {
                validationResult.AddError("Name.Null", "Name cannot be null.");
            }

            if (subscriptionPlan.Description == null)
            {
                validationResult.AddError("Description.Null", "Description cannot be null.");
            }

            // Range checks.
            if (subscriptionPlan.SalesAgentLimit < 1 || subscriptionPlan.SalesAgentLimit > 500)
            {
                validationResult.AddError("SalesAgentLimit.Range", "SalesAgentLimit is outside of expected ranges. SalesAgentLimit should be between 1 and 500.");
            }

            if (subscriptionPlan.PricePerMonth < 0 || subscriptionPlan.PricePerMonth > long.MaxValue)
            {
                validationResult.AddError("PricePerMonth.Range", "PricePerMonth can not be less than 0. Also, the upper limit cannot exceed the max value of the long data type.");
            }

            return(validationResult);
        }
コード例 #16
0
        public static UserPaymentPlan FromDB(dynamic record)
        {
            if (record == null)
            {
                return(null);
            }

            SubscriptionPlan plan = SubscriptionPlan.Free;

            if (!Enum.TryParse <SubscriptionPlan>(record.paymentPlan, true, out plan))
            {
                throw new FormatException("[[[Bad stored payment plan]]]");
            }

            return(new UserPaymentPlan
            {
                userPaymentPlanID = record.userPaymentPlanID,
                userID = record.userID,
                subscriptionID = record.subscriptionID,
                paymentPlan = plan,
                paymentMethod = record.paymentMethod,
                paymentPlanLastChangedDate = record.paymentPlanLastChangedDate,
                nextPaymentDueDate = record.nextPaymentDueDate,
                nextPaymentAmount = record.nextPaymentAmount,
                firstBillingDate = record.firstBillingDate,
                subscriptionEndDate = record.subscriptionEndDate,
                paymentMethodToken = record.paymentMethodToken,
                paymentExpiryDate = record.paymentExpiryDate,
                planStatus = record.planStatus,
                daysPastDue = record.daysPastDue
            });
        }
コード例 #17
0
 public ReSubscriber(
     List <KeyValuePair <string, string> > badges,
     List <KeyValuePair <string, string> > badgeInfo,
     string colorHex,
     Color color,
     string displayName,
     string emoteSet,
     string id,
     string login,
     string systemMessage,
     string msgId,
     string msgParamCumulativeMonths,
     string msgParamStreakMonths,
     bool msgParamShouldShareStreak,
     string systemMessageParsed,
     string resubMessage,
     SubscriptionPlan subscriptionPlan,
     string subscriptionPlanName,
     string roomId,
     string userId,
     bool isModerator,
     bool isTurbo,
     bool isSubscriber,
     bool isPartner,
     string tmiSentTs,
     UserType userType,
     string rawIrc,
     string channel,
     int months = 0)
     : base(badges,
            badgeInfo,
            colorHex,
            color,
            displayName,
            emoteSet,
            id,
            login,
            systemMessage,
            msgId,
            msgParamCumulativeMonths,
            msgParamStreakMonths,
            msgParamShouldShareStreak,
            systemMessageParsed,
            resubMessage,
            subscriptionPlan,
            subscriptionPlanName,
            roomId,
            userId,
            isModerator,
            isTurbo,
            isSubscriber,
            isPartner,
            tmiSentTs,
            userType,
            rawIrc,
            channel,
            months)
 {
 }
コード例 #18
0
ファイル: SubEventArgs.cs プロジェクト: Foxite/zerda
 public SubEventArgs(string username, string?message, string cumulativeMonths, string streakMonths, SubscriptionPlan plan)
 {
     Username         = username;
     Message          = message;
     CumulativeMonths = int.Parse(cumulativeMonths);
     StreakMonths     = int.Parse(streakMonths);
     Plan             = plan;
 }
コード例 #19
0
        /// <summary>
        /// Updates the subscription plan asynchronous.
        /// </summary>
        /// <param name="subscriptionPlan">The subscription plan.</param>
        /// <returns></returns>
        public async Task <int> UpdateAsync(SubscriptionPlan subscriptionPlan)
        {
            int res = await _subscriptionDataService.UpdateAsync(subscriptionPlan);

            _subscriptionPlanProvider.Update(subscriptionPlan);

            return(res);
        }
コード例 #20
0
        /// <summary>
        /// Updates the subscription plan asynchronously.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <returns></returns>
        public async Task <int> UpdateAsync(SubscriptionPlan plan)
        {
            // By definition only the plan name can be updated
            var dbPlan = await FindAsync(plan.Id);

            dbPlan.Name = plan.Name;
            return(await _dbContext.SaveChangesAsync());
        }
コード例 #21
0
        public void GetOrganizationSubscriptionPlan_WhenCalled_ReturnOrganizationSubscriptionPlan()
        {
            var subscriptionPlan = new SubscriptionPlan("id", "name", 1, 1, 1);

            _repo.Setup(x => x.GetOrganizationSubscriptionPlan("organizationId", default))
            .ReturnsAsync(subscriptionPlan);

            var result = _sut.GetOrganizationSubscriptionPlan(default).Result;
コード例 #22
0
        public ActionResult DeleteConfirmed(int id)
        {
            SubscriptionPlan subscriptionPlan = db.SubscriptionPlan.Find(id);

            db.SubscriptionPlan.Remove(subscriptionPlan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #23
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            SubscriptionPlan sp = new SubscriptionPlan(_Product);

            this.Save(sp);
            ShowEditForm();
            SubscriptionsLink.Visible = true;
        }
コード例 #24
0
        public void SetUp()
        {
            _service = new Mock <IGetOrganizationInfoService>();
            _sut     = new GetOrganizationInfoQueryHandler(_service.Object);

            _query = new GetOrganizationInfoQuery();

            _subscriptionPlan = new SubscriptionPlan("id", "plan", 1, 1, 1);
            _service.Setup(x => x.GetOrganizationSubscriptionPlan(default))
コード例 #25
0
        /// <summary>
        /// Updates the specified plan.
        /// </summary>
        /// <param name="plan">The plan.</param>
        /// <returns></returns>
        public object Update(SubscriptionPlan plan)
        {
            var res = PlanService.Update(plan.Id, new StripePlanUpdateOptions
            {
                Name = plan.Name
            });

            return(res);
        }
コード例 #26
0
        /// <summary>
        /// Activates this subscription
        /// </summary>
        public void Activate()
        {
            SubscriptionPlan sp = this.SubscriptionPlan;

            this.ExpirationDate = sp.CalculateExpiration();
            this.IsActive       = true;
            this.GroupId        = sp.GroupId;
            this.Save();
        }
コード例 #27
0
        protected override void Seed(MyNotes.Models.ApplicationDbContext context)
        {
            //  This method will be called after migrating to the latest version.

            var basicMonthly = new SubscriptionPlan
            {
                Id                = "basic_monthly",
                Name              = "Basic",
                Interval          = SubscriptionPlan.SubscriptionInterval.Monthly,
                TrialPeriodInDays = 30,
                Price             = 10.00,
                Currency          = "USD"
            };

            basicMonthly.Properties.Add(new SubscriptionPlanProperty {
                Key = "MaxNotes", Value = "100"
            });

            var professionalMonthly = new SubscriptionPlan
            {
                Id                = "professional_monthly",
                Name              = "Professional",
                Interval          = SubscriptionPlan.SubscriptionInterval.Monthly,
                TrialPeriodInDays = 30,
                Price             = 20.00,
                Currency          = "USD"
            };

            professionalMonthly.Properties.Add(new SubscriptionPlanProperty
            {
                Key   = "MaxNotes",
                Value = "10000"
            });

            var businessMonthly = new SubscriptionPlan
            {
                Id                = "business_monthly",
                Name              = "Business",
                Interval          = SubscriptionPlan.SubscriptionInterval.Monthly,
                TrialPeriodInDays = 30,
                Price             = 30.00,
                Currency          = "USD"
            };

            businessMonthly.Properties.Add(new SubscriptionPlanProperty
            {
                Key   = "MaxNotes",
                Value = "1000000"
            });

            context.SubscriptionPlans.AddOrUpdate(
                sp => sp.Id,
                basicMonthly,
                professionalMonthly,
                businessMonthly);
        }
コード例 #28
0
        public void SetUp()
        {
            _repo = new Mock <IUploadMediaRepository>();
            _subscriptionManager = new Mock <IOrganizationSubscriptionManager>();
            _appResourceManager  = new Mock <IAppResourceManager>();
            _sut = new UploadMediaService(_repo.Object, _subscriptionManager.Object, _appResourceManager.Object);

            var subscription = new SubscriptionPlan("id", "subscription", 20, 1, 10);

            _subscriptionManager.Setup(x => x.GetOrganizationSubscriptionPlan(default)).ReturnsAsync(subscription);
コード例 #29
0
        public void ConstructorWithIdNameMaxStorageMaxUsers_WhenCalled_SetRequiredPropertiesCorrectly()
        {
            _sut = new SubscriptionPlan("id", "name", 100, 1, 10);

            Assert.That(_sut.Id, Is.EqualTo("id"));
            Assert.That(_sut.Name, Is.EqualTo("name"));
            Assert.That(_sut.MaxStorage, Is.EqualTo(100));
            Assert.That(_sut.MaxFileSize, Is.EqualTo(1));
            Assert.That(_sut.MaxUsers, Is.EqualTo(10));
        }
コード例 #30
0
        /// <summary>
        /// Calculate subscription payment based on subscription level and term
        /// </summary>
        /// <param name="subscriptionPlan">customer's subscription plan</param>
        /// <returns>subscription payment customer should pay</returns>
        public double CalculatePayment(SubscriptionPlan subscriptionPlan)
        {
            IPaymentStrategy paymentStrategy = _paymentStrategyFactory.GetPaymentStratgey(subscriptionPlan.Level.ToString());

            if (paymentStrategy == null)
            {
                return(-1d);
            }

            return(paymentStrategy.CalculatePayment(subscriptionPlan));
        }
 public int Save(string email, string plan)
 {
     var subscriptionPlan = SubscriptionPlans.SingleOrDefault(
     p => p.Email == email);
     if(subscriptionPlan == null)
     {
     subscriptionPlan = new SubscriptionPlan();
     subscriptionPlan.Id = AutoId;
     SubscriptionPlans.Add(subscriptionPlan);
     }
     subscriptionPlan.Email = email;
     subscriptionPlan.Plan = plan;
     return subscriptionPlan.Id;
 }
コード例 #32
0
 /// <summary>
 /// Initializes a new instance of the Lynda.Test.ConsumerPages.OTLSubscriptionPlan class.
 /// </summary>
 /// <param name="subscriptionPlan">Specifies how to initialize the subscription plan.</param>
 internal OTLSubscriptionPlanRegPage1(SubscriptionPlan subscriptionPlan)
     : this()
 {
     Subscription = subscriptionPlan;
 }