コード例 #1
0
        public void DeleteRel(Relationship rel)
        {
            RelEntity entity = UnitOfWork.FindById <RelEntity>(rel.id);

            UnitOfWork.Remove(entity);
            UnitOfWork.SaveChanges();
        }
コード例 #2
0
 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;
 }
コード例 #3
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);
        }
コード例 #4
0
        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();
        }
コード例 #5
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);
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
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);
        }
コード例 #10
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);
        }
コード例 #11
0
        public Relationship GetRelById(int id)
        {
            RelEntity entity = Rels.FirstOrDefault(p => p.id == id);

            return(FromEntity.ToRel(entity));
        }