コード例 #1
0
 private Task <List <Subscription> > GetSubscriptions(SubscriptionFrequency frequency)
 {
     return(db.Subscriptions
            .Include(s => s.User)
            .Include(s => s.Product)
            .Where(s => s.Frequency == frequency)
            .ToListAsync());
 }
コード例 #2
0
 //Constructor without nullable aspects
 public Subscription(long SID, long accID, long rID, DateTime purchaseDate, decimal purchaseAmount, SubscriptionFrequency frequency)
 {
     this.accID          = accID;
     this.SID            = SID;
     this.purchaseDate   = purchaseDate;
     this.purchaseAmount = purchaseAmount;
     this.frequency      = frequency;
 }
コード例 #3
0
 //Setters
 public void setSubscriptionFrequency(SubscriptionFrequency frequency)
 {
     if (frequency.Equals(this.frequency))
     {
         return;
     }
     this.frequency = frequency;
     changed        = true;
 }
コード例 #4
0
ファイル: Configuration.cs プロジェクト: sondaa/Stockwinners
        private static void SeedSubscriptionTypesAndFrequencies(DatabaseContext context)
        {
            SubscriptionFrequency monthly = context.SubscriptionFrequencies.FirstOrDefault(st => st.Name == PredefinedSubscriptionFrequencies.Monthly);

            if (monthly == null)
            {
                monthly = new SubscriptionFrequency()
                {
                    Name = PredefinedSubscriptionFrequencies.Monthly
                };
                context.SubscriptionFrequencies.Add(monthly);
            }

            SubscriptionFrequency quarterly = context.SubscriptionFrequencies.FirstOrDefault(st => st.Name == PredefinedSubscriptionFrequencies.Quarterly);

            if (quarterly == null)
            {
                quarterly = new SubscriptionFrequency()
                {
                    Name = PredefinedSubscriptionFrequencies.Quarterly
                };
                context.SubscriptionFrequencies.Add(quarterly);
            }

            SubscriptionFrequency yearly = context.SubscriptionFrequencies.FirstOrDefault(st => st.Name == PredefinedSubscriptionFrequencies.Yearly);

            if (yearly == null)
            {
                yearly = new SubscriptionFrequency()
                {
                    Name = PredefinedSubscriptionFrequencies.Yearly
                };
                context.SubscriptionFrequencies.Add(yearly);
            }

            context.SaveChanges();

            context.SubscriptionTypes.AddOrUpdate(st => st.Price,
                                                  new SubscriptionType()
            {
                SubscriptionFrequencyId = monthly.SubscriptionFrequencyId, SubscriptionFrequency = monthly, Price = 39, IsAvailableToUsers = false, IsAddOn = false, Name = "Monthly Subscription"
            },
                                                  new SubscriptionType()
            {
                SubscriptionFrequencyId = quarterly.SubscriptionFrequencyId, SubscriptionFrequency = quarterly, Price = 110, IsAvailableToUsers = false, IsAddOn = false, Name = "Quarterly Subscription"
            },
                                                  new SubscriptionType()
            {
                SubscriptionFrequencyId = yearly.SubscriptionFrequencyId, SubscriptionFrequency = yearly, Price = 350, IsAvailableToUsers = false, IsAddOn = false, Name = "Yearly Subscription"
            },
                                                  new SubscriptionType()
            {
                SubscriptionFrequencyId = monthly.SubscriptionFrequencyId, SubscriptionFrequency = monthly, Price = 10, IsAvailableToUsers = true, IsAddOn = true, Name = "Auto Trading", Description = "Auto trading enables you to have our registered brokers trade our selections on your behalf. With auto trading, our selections are automatically traded on your behalf based on allocation rules that you specify. We've partnered with EOption to enable this functionality and its use requires having an account with EOption. Please refer to http://eoption.com/auto_trading.html for more information on auto trading."
            }
                                                  );
        }
コード例 #5
0
 //FULL Constructor
 public Subscription(long SID, long accID, long RID, DateTime purchaseDate, string notes, decimal purchaseAmount, SubscriptionFrequency frequency)
 {
     this.accID          = accID;
     this.SID            = SID;
     this.RID            = RID;
     this.purchaseDate   = purchaseDate;
     this.notes          = notes;
     this.purchaseAmount = purchaseAmount;
     this.frequency      = frequency;
 }
コード例 #6
0
        private async Task Run(SubscriptionFrequency frequency)
        {
            using (var tx = await db.Database.BeginTransactionAsync())
            {
                var subscriptions = await GetSubscriptions(frequency);

                foreach (var subscription in subscriptions)
                {
                    Process(subscription);
                }

                await db.SaveChangesAsync();

                tx.Commit();
            }
        }
コード例 #7
0
        public Subscription CreateOrUpdate(string userId, int productId, int quantity, SubscriptionFrequency frequency)
        {
            var sub = GetAll().FirstOrDefault(x => x.UserId == userId && x.ProductId == productId);

            if (sub == null)
            {
                sub = new Subscription
                {
                    UserId    = userId,
                    ProductId = productId
                };

                db.Subscriptions.Add(sub);
            }

            sub.Quantity  = quantity;
            sub.Frequency = frequency;

            db.SaveChanges();

            return(sub);
        }