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

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

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

            return(channel.Put(new Relate()
            {
                Primary = primary,
                PrimaryType = primaryType,
                Secondary = secondary,
                SecondaryType = secondaryType,
                ForeignKeySpecifier = keySpecifier
            }));
        }
Example #2
0
        private static Update UpdateCore(Write <CommandChannel <Command> > channel, object entity)
        {
            if (entity == null)
            {
                throw new TectureOrmFeatureException("Entity going to be added cannot be null");
            }

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

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

            return(channel.Put(new Update(entity, t)));
        }
Example #3
0
        private static Update UpdateCore(Write <CommandChannel <Command> > ppl, object entity, LambdaExpression[] properties)
        {
            if (entity == null)
            {
                throw new TectureOrmFeatureException("Entity going to be updated cannot be null");
            }

            var t  = entity.GetType();
            var fe = ppl.Feature();

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

            return(ppl.Put(new Update(entity, t, properties)));
        }
Example #4
0
        private static Delete DeleteCore(Write <CommandChannel <Command> > channel, object entity)
        {
            if (entity == null)
            {
                throw new TectureOrmFeatureException("Entity going to be deleted cannot be null");
            }

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

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

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

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

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

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