public void DeleteRel(Relationship rel) { RelEntity entity = UnitOfWork.FindById <RelEntity>(rel.id); UnitOfWork.Remove(entity); UnitOfWork.SaveChanges(); }
public static void FromRelationship(Relationship rel, RelEntity entity) { entity.username = rel.username; entity.orgId = rel.orgId; entity.pageId = rel.pageId; entity.relText = rel.relText; entity.relTypeId = rel.relTypeId; }
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 void SetContributeAutoApprovedInProject(int projectid, Guid userId, int organisationId) { var rel = new RelEntity() { pageId = projectid, UserId = userId, relTypeId = 4, relDateTime = DateTime.Now, Approved = true, Pending = true, orgID = organisationId }; UnitOfWork.Add(rel); UnitOfWork.SaveChanges(); }
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 void WatchProject(int projectid, Guid userId, int organisationId) { if (!IsWatched(projectid, userId)) { var rel = new RelEntity() { pageId = projectid, UserId = userId, relTypeId = 3, relDateTime = DateTime.Now, Approved = true, orgID = organisationId }; UnitOfWork.Add(rel); UnitOfWork.SaveChanges(); } }
public bool RelToUserToPage(int pageID) { bool _RelToUserToPage = false; RelEntity entity = Rels.FirstOrDefault(p => p.username == pageID.ToString()); _RelToUserToPage = true; if (entity != null) { if (entity.pageId == pageID) { _RelToUserToPage = true; } } return(_RelToUserToPage); }
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); }
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); }
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 Relationship GetRelById(int id) { RelEntity entity = Rels.FirstOrDefault(p => p.id == id); return(FromEntity.ToRel(entity)); }