public static void AddEvents(Organization org, ICollection<OrganizationEventRel> list)
 {
     foreach (var rel in list)
     {
         var c = rel.Event;
         var @event = new Domain.Models.Event()
         {
             Id = c.Id,
             Name = c.EventName,
             Summary = c.Summary,
             SecurityLevel = c.ConfidentialityTypeId == 1 ? SecurityLevel.EyesOnly : SecurityLevel.Open,
             DocumentationType = (DocumentationType)c.EventDocumentationTypeId,
             //todo: EventType
             //                        EventType =
             Movement = Helpers.ConvertMovementId(c.MovementClassId),
             EventDate = c.EventDate,
             DateCreated = c.DateCreated,
             DateUpdated = c.DateModified,
             LogEntries = new List<EventLogEntry>()
         };
         @event.LogEntries.Add(new EventLogEntry() { Note = $"Added event {@event.Name}" });
         org.LogEntries.Add(new OrganizationLogEntry() { Note = $"Added event {@event.Name}" });
         org.Events.Add(@event);
     }
 }
        public static void LoadEvents(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.Events.Count();
            var entityName = "Event";

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

                    foreach (var item in db.Events.OrderBy(x => x.Id).Skip(skip ?? 0).Take(takecount ?? 0))
                    {
                        count++;
                        var i = context.Events.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.Event()
                        {
                            Id = item.Id,
                            Name = item.EventName?.Trim(),
                            Summary = item.Summary?.Trim(),
                            SecurityLevel =
                                item.ConfidentialityTypeId == 1 ? SecurityLevel.EyesOnly : SecurityLevel.Open,
                            //                            DocumentationType = (DocumentationType)item.EventDocumentationTypeId,
                            //                            DocumentationType = Helpers.ConvertEventDocType(item.EventDocumentationTypeId),
                            //todo: EventType
                            //                        EventType =
                            Movement = Helpers.ConvertMovementId(item.MovementClassId),
                            EventDate = item.EventDate,
                            DateCreated = item.DateCreated,
                            DateUpdated = item.DateModified
                        };
                        newItem.LogEntries.Add(new EventLogEntry() { Note = $"Added {entityName} {newItem.Name}" });
                        context.Events.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 Events 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));
            }
        }