Beispiel #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);
            }
        }
Beispiel #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);
        }