Exemplo n.º 1
0
        public int Save(UnionRelationshipDTO item)
        {
            using (var projectContext = new MyIdeaEntities())
            {
                UnionRelationshipType dbItem = null;
                if (item.ID == 0)
                {
                    dbItem = new UnionRelationshipType();
                    projectContext.UnionRelationshipType.Add(dbItem);
                }
                else
                {
                    dbItem = projectContext.UnionRelationshipType.First(x => x.ID == item.ID);
                }

                dbItem.Name = item.Name;
                dbItem.IsTolatParticipation = item.IsTolatParticipation;
                dbItem.UnionHoldsKeys       = item.UnionHoldsKeys;
                projectContext.SaveChanges();
                return(dbItem.ID);
            }
        }
Exemplo n.º 2
0
        public UnionRelationshipDTO ToUnionRelationshipDTO(UnionRelationshipType item)
        {
            UnionRelationshipDTO result = new UnionRelationshipDTO();

            result.Name = item.Name;
            result.ID   = item.ID;
            result.IsTolatParticipation = item.IsTolatParticipation;
            result.UnionHoldsKeys       = item.UnionHoldsKeys;
            result.SuperTypeEntities    = "";
            foreach (var superType in item.UnionToSubUnionRelationshipType)
            {
                if (!result.SuperTypeEntities.Contains(superType.RelationshipType.Relationship.TableDrivedEntity.Name))
                {
                    result.SuperTypeEntities += (result.SuperTypeEntities == "" ? "" : ",") + superType.RelationshipType.Relationship.TableDrivedEntity.Name;
                }
            }
            result.SubTypeEntities = "";
            foreach (var subType in item.SubUnionToUnionRelationshipType)
            {
                result.SubTypeEntities += (result.SubTypeEntities == "" ? "" : ",") + subType.RelationshipType.Relationship.TableDrivedEntity.Name;
            }
            return(result);
        }
Exemplo n.º 3
0
 public void MergeUnionRelationships(string name, List <UnionRelationshipDTO> relationships, UnionRelationshipDTO selectedOne)
 {
     using (var projectContext = new MyIdeaEntities())
     {
         //   int UnionRelationID = 0;
         foreach (var relationship in relationships)
         {
             //if (relationship == selectedOne)
             //    UnionRelationID = relationship.ID;
             //else
             //{
             var dbRelationship = projectContext.UnionRelationshipType.First(x => x.ID == relationship.ID);
             foreach (var detail in dbRelationship.UnionToSubUnionRelationshipType)
             {
                 detail.UnionRelationshipTypeID = selectedOne.ID;
             }
             foreach (var detail in dbRelationship.SubUnionToUnionRelationshipType)
             {
                 detail.UnionRelationshipTypeID = selectedOne.ID;
             }
             //}
         }
         projectContext.SaveChanges();
     }
 }