public Models.ActionItem createNewActionItem(Models.User creator, Models.Release release, Models.ActionItem toCreate, Models.User assignedTo)
        {
            toCreate.AssignedTo = new List<Models.User>(){ assignedTo };

            SQLActionItem toInsert = new SQLActionItem()
            {
                ActionItemTypeId = toCreate.CurrentType.ID,
                CreatedByUserId = toCreate.CreatedBy.ID,
                CurrentPriority = toCreate.CurrentPriority.Order,
                CurrentStatusId = toCreate.CurrentStatus.ID,
                DateCompleted = toCreate.DateCompleted,
                DateCreated = toCreate.DateCreated,
                Description = toCreate.Description,
                ID = toCreate.ID == Guid.Empty ? Guid.NewGuid() : toCreate.ID,
                Estimate = null,
                InReleaseId = release.ID,
                Name = toCreate.Title,
                TimeSpent = null
            };

            #warning this should accept multiple users instead of just one
            SQLActionItemUser assignmentsToCreate = new SQLActionItemUser()
            {
                ActionItemId = toInsert.ID,
                AssignedToUserID = assignedTo.ID
            };

            if (toCreate.Estimate.HasValue)
                toInsert.Estimate = toCreate.Estimate.Value.Ticks;

            if (toCreate.TimeSpent.HasValue)
                toInsert.TimeSpent = toCreate.TimeSpent.Value.Ticks;

            db.SQLActionItems.Add(toInsert);
            db.SaveChanges();
            db.SQLActionItemUsers.Add(assignmentsToCreate);
            List<SQLActionItemHistory> historicEvents = new List<SQLActionItemHistory>();

            if (toInsert.Estimate.HasValue)
            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set estimate to: {0}", toInsert.Estimate.Value),
                ThingChanged = "Estimate"
            });

            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set type to: {0}", toInsert.ActionItemType.Name),
                ThingChanged = "Type"
            });

            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set priority to: {0}", toInsert.CurrentPriority),
                ThingChanged = "Priority"
            });

            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set status to: {0}", toInsert.Status.Name),
                ThingChanged = "Status"
            });

            if (toInsert.DateCompleted.HasValue)
            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set completion date to: {0}", toInsert.DateCompleted.Value),
                ThingChanged = "Date Completed"
            });

            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set action-item description: {0}", toInsert.Description),
                ThingChanged = "Description"
            });

            if (toInsert.IndividualTargetDate.HasValue)
            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set target date: {0}", toInsert.IndividualTargetDate.Value),
                ThingChanged = "Target Date"
            });

            var toAdd = new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = "",
                ThingChanged = "Assigned To"
            };
            foreach (var assignedUser in toInsert.ActionItemUsers)
            {
                if (assignedUser.User != null)
                toAdd.DescriptionOfChange += string.Format("{0},", assignedUser.User.Email);
            }
            historicEvents.Add(toAdd);

            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set title to: {0}", toInsert.Name),
                ThingChanged = "Title"
            });

            if (toInsert.TimeSpent.HasValue)
            historicEvents.Add(new SQLActionItemHistory()
            {
                ActionItemID = toInsert.ID,
                DescriptionOfChange = string.Format("set time spent to: {0}", toInsert.TimeSpent.Value),
                ThingChanged = "Time Spent"
            });

            Guid createEventID = Guid.NewGuid();

            foreach (var history in historicEvents)
            {
                history.ID = Guid.NewGuid();
                history.ChangeGrouping = createEventID;
                history.ChangedWhen = toInsert.DateCreated;
                history.ChangedBy = creator.ID;
                db.SQLActionItemHistories.Add(history);
            }

            db.SaveChanges();

            return toCreate;
        }
        private List<SQLActionItemHistory> findDifferences(SQLActionItem oldItem, Models.ActionItem newItem)
        {
            List<SQLActionItemHistory> returnMe = new List<SQLActionItemHistory>();

            var actionType = oldItem.GetType();
            var properties = actionType.GetProperties();

            #warning TODO:  Use reflection for this when you have time to figure out how to easily get user-friendly names for properties
            //foreach (var prop in properties)
            //{
            //    var oldProp = prop.GetValue(oldItem);
            //    var newProp = prop.GetValue(newItem);

            //    if (oldProp != newProp)
            //    {
            //        returnMe.Add(new SQLActionItemHistory()
            //        {
            //            ActionItemID = newItem.ID,
            //            DescriptionOfChange = newProp.ToString(),
            //            ThingChanged = prop.Name,
            //            ID = Guid.NewGuid()
            //        });
            //    }
            //}

            if (oldItem.Estimate != (newItem.Estimate.HasValue ? newItem.Estimate.Value : new TimeSpan(0)).TotalMilliseconds)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = newItem.Estimate.HasValue ? string.Format("updated estimate to: {0}", newItem.Estimate.Value) : "removed estimate",
                    ThingChanged = "Estimate"
                });

            if (oldItem.ActionItemTypeId != newItem.CurrentType.ID)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = string.Format("updated type to: {0}", newItem.CurrentType.Title),
                    ThingChanged = "Type"
                });

            if (oldItem.CurrentPriority != newItem.CurrentPriority.Order)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = string.Format("updated priority to: {0}", newItem.CurrentPriority.Name),
                    ThingChanged = "Priority"
                });

            if (oldItem.Status.ID != newItem.CurrentStatus.ID)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = string.Format("updated status to: {0}", newItem.CurrentStatus.Name),
                    ThingChanged = "Status"
                });

            if (oldItem.DateCompleted != newItem.DateCompleted)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = oldItem.DateCompleted.HasValue ?
                        (newItem.DateCompleted.HasValue ? string.Format("updated completed date / time to: {0}", newItem.DateCompleted.Value) : "removed completion date / time") :
                        (newItem.DateCompleted.HasValue ? string.Format("added a completion date / time: {0}", newItem.DateCompleted.Value) : ""),
                    ThingChanged = "Date Completed"
                });

            if (oldItem.Description != newItem.Description)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = "updated action-item description",
                    ThingChanged = "Description"
                });

            if (oldItem.IndividualTargetDate != newItem.TargetDate)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = oldItem.IndividualTargetDate.HasValue ?
                        (newItem.TargetDate.HasValue ? string.Format("updated target date / time to: {0}", newItem.TargetDate.Value) : "removed target date / time") :
                        (newItem.TargetDate.HasValue ? string.Format("added a target date / time: {0}", newItem.TargetDate.Value) : ""),
                    ThingChanged = "Target Date"
                });

            if (oldItem.ActionItemUsers.Select(x => x.User.Email).OrderBy(y => y) != newItem.AssignedTo.Select(x => x.Email).OrderBy(y => y))
            {
                var toAdd = new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = "",
                    ThingChanged = "Assigned To"
                };
                foreach (var assignedUser in oldItem.ActionItemUsers)
                {
                    toAdd.DescriptionOfChange += string.Format("{0},", assignedUser.User.Email);
                }
                returnMe.Add(toAdd);
            }

            if (oldItem.Name != newItem.Title)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = string.Format("updated title to: {0}", newItem.Title),
                    ThingChanged = "Title"
                });

            if (newItem.TimeSpent != newItem.TimeSpent)
                returnMe.Add(new SQLActionItemHistory()
                {
                    ActionItemID = oldItem.ID,
                    DescriptionOfChange = newItem.TimeSpent.HasValue ? string.Format("updated time spent to: {0}", newItem.TimeSpent.Value) : "removed time spent",
                    ThingChanged = "Time Spent"
                });

            return returnMe;
        }