public static void AddSubscriptions(Organization org, ICollection<OrganizationSubscriptionRel> list)
 {
     foreach (var rel in list)
     {
         var c = rel.Subscription;
         var subscription = new Domain.Models.Subscription()
         {
             Id = c.Id,
             Name = c.PublicationName,
             Rate = c.SubscriptionRate,
             RenewalDate = c.RenewalPermissionDate,
             DateCreated = c.DateCreated,
             DateUpdated = c.DateModified,
             LogEntries = new List<SubscriptionLogEntry>()
         };
         subscription.LogEntries.Add(new SubscriptionLogEntry() { Note = $"Added subscription {subscription.Name}" });
         org.LogEntries.Add(new OrganizationLogEntry() { Note = $"Added subscription {subscription.Name}" });
         org.Subscriptions.Add(subscription);
     }
 }
        public static void LoadSubscriptions(int? skip = 0, int? takecount = 0)
        {
            var startTime = DateTime.Now;
            var w = FluentConsole.Instance;
            var db = new ACDBContext();
            var count = 0;
            var savedCount = 0;
            if (takecount == 0) takecount = db.Subscriptions.Count();
            var entityName = "Subscription";

            using (var context = new AppContext())
            {
                using (var trans = context.Database.BeginTransaction())
                {
                    context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Subscriptions ON");
                    w.White.Line($"Creating {takecount} {entityName}s");

                    foreach (var item in db.Subscriptions.OrderBy(x => x.Id).Skip(skip ?? 0).Take(takecount ?? 0))
                    {
                        count++;
                        var i = context.Subscriptions.Find(item.Id);
                        if (i != null)
                        {
                            w.Yellow.Line($"Adding {entityName} {count} of {takecount}: {entityName} {i.Name} already exists");
                            continue;
                        }

                        var newItem = new Domain.Models.Subscription()
                        {
                            Id = item.Id,
                            Name = item.PublicationName?.Trim(),
                            Rate = item.SubscriptionRate?.Trim(),
                            RenewalDate = item.RenewalPermissionDate,
                            DateCreated = item.DateCreated,
                            DateUpdated = item.DateModified
                        };
                        newItem.LogEntries.Add(new SubscriptionLogEntry() { Note = $"Added {entityName} {newItem.Name}" });
                        context.Subscriptions.Add(newItem);
                        w.Green.Line($"Adding {count} of {takecount} {entityName}: {newItem.Name}");
                        savedCount++;
                        context.SaveChanges();
                    }
                    w.Gray.Line($"Saving {entityName}s...");
                    context.SaveChanges();
                    context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT Subscriptions OFF");
                    trans.Commit();
                }
                var totalTime = DateTime.Now - startTime;
                w.Green.Line($"Saved {savedCount} {entityName}s in {totalTime.Hours}:{totalTime.Minutes}:{totalTime.Seconds} ");
                w.White.Line(new String('-', 15));
            }
        }