Exemplo n.º 1
0
        public bool Set([FromBody]RelationModel model)
        {
            var relation = new Relation()
            {
                AccountId = model.aid,
                EntityId = model.eid,
                Type = model.type
            };
            var r = provider.AddRelation2(relation);

               return true;
        }
Exemplo n.º 2
0
        public Entity.Relation AddRelation(Entity.Relation relation)
        {
            FindOneAndUpdateOptions <Entity.Relation> options = new FindOneAndUpdateOptions <Entity.Relation> {
                IsUpsert = true
            };

            Expression <Func <Entity.Relation, bool> > exp = o => o.AccountId == relation.AccountId && o.EntityId == relation.EntityId && o.Type == relation.Type;

            var update = Builders <Relation> .Update
                         .Set(r => r.AccountId, relation.AccountId)
                         .Set(r => r.EntityId, relation.EntityId)
                         .Set(r => r.Type, relation.Type);

            var re = this.FindOneAndReplace(exp, relation, true);

            return(re ?? relation);
        }
Exemplo n.º 3
0
        public bool SetMulti([FromBody] RelationModel model)
        {
            foreach (string item in model.aids)
            {
                var relation = new Relation()
                {
                    AccountId = item,
                    EntityId = model.eid,
                    Type =model.type
                };
                provider.AddRelation(relation);
            }

            return true;
        }