FromRelationship() public static method

public static FromRelationship ( Relationship rel, RelEntity entity ) : void
rel Relationship
entity RelEntity
return void
コード例 #1
0
        public Relationship AddNewRel(Relationship rel, int reltypeid, string username, int orgID, int pageID, string reltext)
        {
            RelEntity relEntity = new RelEntity();

            ToEntity.FromRelationship(rel, relEntity);
            relEntity.username    = username;
            relEntity.orgId       = orgID;
            relEntity.pageId      = pageID;
            relEntity.relDateTime = DateTime.Now;
            UnitOfWork.Add(relEntity);
            UnitOfWork.SaveChanges();

            Relationship newrel = FromEntity.ToRel(relEntity);

            return(newrel);
        }
コード例 #2
0
        public Relationship SaveOrUpdateRel(Relationship rel)
        {
            RelEntity entity = UnitOfWork.FindById <RelEntity>(rel.Id);

            if (entity == null)
            {
                entity = new RelEntity();
                ToEntity.FromRelationship(rel, entity);
                UnitOfWork.Add(entity);
                UnitOfWork.SaveChanges();
                rel = FromEntity.ToRel(entity);
            }
            else
            {
                ToEntity.FromRelationship(rel, entity);
                UnitOfWork.SaveChanges();
                rel = FromEntity.ToRel(entity);
            }

            return(rel);
        }
コード例 #3
0
        public Relationship SaveOrUpdateRel(Relationship rel)
        {
            RelEntity entity = UnitOfWork.FindById <RelEntity>(rel.id);

            if (entity == null)
            {
                entity = new RelEntity();
                ToEntity.FromRelationship(rel, entity);
                UnitOfWork.Add(entity);
                UnitOfWork.SaveChanges();
                rel = FromEntity.ToRel(entity);
            }
            else
            {
                rel.orgID = GetUserByUsername(rel.username).orgID;

                ToEntity.FromRelationship(rel, entity);
                UnitOfWork.SaveChanges();
                rel = FromEntity.ToRel(entity);
            }

            return(rel);
        }