Beispiel #1
0
        public int UpdateEntityRelationshipTailDataMenu(EntityRelationshipTailDataMenuDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                EntityRelationshipTailDataMenu dbItem = null;
                if (message.ID == 0)
                {
                    dbItem = new EntityRelationshipTailDataMenu();
                    projectContext.EntityRelationshipTailDataMenu.Add(dbItem);
                }
                else
                {
                    dbItem = projectContext.EntityRelationshipTailDataMenu.First(x => x.ID == message.ID);
                }

                dbItem.Name = message.Name;
                dbItem.EntityRelationshipTailID = message.EntityRelationshipTailID;
                while (dbItem.EntityRelationshipTailDataMenuItems.Any())
                {
                    projectContext.EntityRelationshipTailDataMenuItems.Remove(dbItem.EntityRelationshipTailDataMenuItems.First());
                }
                foreach (var fitem in message.Items.Where(x => x.DataMenuSettingID != 0))
                {
                    dbItem.EntityRelationshipTailDataMenuItems.Add(new EntityRelationshipTailDataMenuItems()
                    {
                        DataMenuSettingID = fitem.DataMenuSettingID,
                        Path = fitem.Path,
                        TableDrivedEntityID = fitem.TableDrivedEntityID
                    });
                }
                projectContext.SaveChanges();
                return(dbItem.ID);
            }
        }
Beispiel #2
0
        public EntityRelationshipTailDataMenuDTO ToEntityRelationshipTailDataMenuDTO(EntityRelationshipTailDataMenu item, bool withDetails)
        {
            EntityRelationshipTailDataMenuDTO result = new EntityRelationshipTailDataMenuDTO();

            result.ID = item.ID;

            result.EntityRelationshipTailID = item.EntityRelationshipTailID;
            result.Name = item.Name;
            foreach (var fitem in item.EntityRelationshipTailDataMenuItems)
            {
                result.Items.Add(new EntityRelationshipTailDataMenuItemsDTO()
                {
                    ID = fitem.ID,
                    DataMenuSettingID = fitem.DataMenuSettingID,
                    Path = fitem.Path,
                    TableDrivedEntityID = fitem.TableDrivedEntityID
                });
            }
            return(result);
        }