Example #1
0
        internal RTLinkChangeGroup AddLinkChangeGroup(LinkChangeGroup group)
        {
            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                var rtLinkChangeGroup = RTLinkChangeGroup.CreateRTLinkChangeGroup(
                    0, (int)group.Status, false, SessionGroupId, SessionId, SourceId);
                rtLinkChangeGroup.GroupName = group.GroupName;
                context.AddToRTLinkChangeGroupSet(rtLinkChangeGroup);

                int newActiveActionCount = 0;
                foreach (LinkChangeAction a in group.Actions)
                {
                    RTLinkChangeAction rtLinkChangeAction = AddChangeAction(a, context);
                    if (rtLinkChangeAction == null)
                    {
                        continue;
                    }

                    rtLinkChangeAction.LinkChangeGroup = rtLinkChangeGroup;
                    ++newActiveActionCount;
                }

                if (newActiveActionCount <= 0)
                {
                    return(null);
                }

                context.TrySaveChanges();
                group.InternalId = rtLinkChangeGroup.Id;
                context.Detach(rtLinkChangeGroup);
                return(rtLinkChangeGroup);
            }
        }