public static void FromRelationship(Relationship rel, RelEntity entity) { entity.id = rel.id; entity.username = rel.username; entity.orgID = rel.orgID; entity.pageId = rel.pageId; entity.relText = rel.relText; entity.relTypeId = rel.relTypeId; }
public Relationship AddNewRel(Relationship rel, int reltypeid, string username, int orgID, int pageID, string reltext) { RelEntity relEntity = new RelEntity(); ToEntity.FromRelationship(rel, relEntity); relEntity.id = 0; relEntity.username = username; User _user = GetUserByUsername(username); relEntity.orgID = _user.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 { rel.orgID = GetUserByUsername(rel.username).orgID; ToEntity.FromRelationship(rel, entity); UnitOfWork.SaveChanges(); rel = FromEntity.ToRel(entity); } return rel; }
public static Relationship ToRel(RelEntity entity) { if (entity == null) return null; Relationship rel = new Relationship(); rel.id = entity.Id; rel.orgID = entity.orgID; rel.username = entity.username; rel.pageId = entity.pageId; rel.relTypeId = entity.relTypeId; rel.relText = entity.relText; rel.relDateTime = entity.relDateTime; return rel; }