ToRel() public static méthode

public static ToRel ( RelEntity entity ) : Relationship
entity RelEntity
Résultat Relationship
Exemple #1
0
        public Relationship RelToUserToPage(int pageID, string username)
        {
            Relationship _RelToUserToPage = new Relationship();

            RelEntity entity = Rels.FirstOrDefault(r => r.username == username && r.pageId == pageID);

            if (entity != null && entity.pageId != 0)
            {
                _RelToUserToPage = FromEntity.ToRel(entity);
            }

            return(_RelToUserToPage);
        }
        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);
        }
        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);
        }
Exemple #4
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);
        }
Exemple #5
0
        public Relationship GetRelById(int id)
        {
            RelEntity entity = Rels.FirstOrDefault(p => p.id == id);

            return(FromEntity.ToRel(entity));
        }