Exemple #1
0
        private static Relate RelateCore(Write <CommandChannel <Command> > channel, object primary, string keySpecifier, object secondary)
        {
            if (primary == null)
            {
                throw new TectureOrmAspectException("Relation between entity and null is impossible. Use Delete/Derelate instead");
            }
            if (secondary == null)
            {
                throw new TectureOrmAspectException("Relation between null and entity is impossible. Use Derelate instead");
            }

            var primaryType   = primary.GetType();
            var secondaryType = secondary.GetType();
            var fe            = channel.Aspect();

            if (!fe.IsSubjectCore(primaryType))
            {
                throw new TectureOrmAspectException($"Entity {primary} can not be referenced in corresponding service");
            }
            if (!fe.IsSubjectCore(secondaryType))
            {
                throw new TectureOrmAspectException($"Entity {secondary} can not make references in corresponding service");
            }

            return(channel.Put(new Relate()
            {
                Primary = primary,
                PrimaryType = primaryType,
                Secondary = secondary,
                SecondaryType = secondaryType,
                ForeignKeySpecifier = keySpecifier
            }));
        }
        public static Aspect101.BuggyCommand PutBuggyCommand(this Write <CommandChannel <Aspect101.Command> > w, string payload)
        {
            var ca = w.Aspect();

            ca.CommandCounter++;
            return(w.Put(new Aspect101.BuggyCommand(payload, ca.CommandCounter)));
        }
Exemple #3
0
        private static Update <T> UpdateCore <T>(Write <CommandChannel <Command> > channel, T entity)
        {
            if (entity == null)
            {
                throw new TectureOrmAspectException("Entity going to be added cannot be null");
            }

            var t  = entity.GetType();
            var fe = channel.Aspect();

            if (!fe.IsSubjectCore(t))
            {
                throw new TectureOrmAspectException($"Entity {entity} is not a subject for addition in corresponding service");
            }

            return(channel.Put(new Update <T>(entity)));
        }
        private static Delete DeleteCore(Write <CommandChannel <Command> > channel, object entity)
        {
            if (entity == null)
            {
                throw new TectureOrmAspectException("Entity going to be deleted cannot be null");
            }

            var t = entity.GetType();
            var f = channel.Aspect();

            if (!f.IsSubjectCore(t))
            {
                throw new TectureOrmAspectException($"Entity {entity} is not a subject for deletion in corresponding service");
            }

            return(channel.Put(new Delete()
            {
                EntityType = t,
                Entity = entity
            }));
        }
Exemple #5
0
        private static Derelate DerelateCore(Write <CommandChannel <Command> > channel, object primary, string keySpecifier)
        {
            if (primary == null)
            {
                throw new TectureOrmAspectException("Derelation between entity and null is impossible");
            }

            var primaryType = primary.GetType();
            var fe          = channel.Aspect();

            if (!fe.IsSubjectCore(primaryType))
            {
                throw new TectureOrmAspectException($"Entity {primary} can not be de-related in corresponding service");
            }

            return(channel.Put(new Derelate()
            {
                Primary = primary,
                PrimaryType = primaryType,
                ForeignKeySpecifier = keySpecifier
            }));
        }