Beispiel #1
0
        private MenuDTO ToMenuDTO(Menu menu)
        {
            if (menu == null)
            {
                return(null);
            }

            MenuDTO parent = null;

            if (menu.Parent != null)
            {
                parent = new MenuDTO {
                    Id   = menu.Parent.Id,
                    Text = menu.Parent.Text
                };
            }

            var result = new MenuDTO {
                Id          = menu.Id,
                Text        = menu.Text,
                Url         = menu.Url,
                Order       = menu.Order,
                Parent      = parent,
                Role        = FromDomainObject <RoleDTO>(menu.Role as Role),
                Children    = FromDomainObject <MenuDTO>(menu.Children),
                CreatedDate = menu.CreatedDate,
                UpdatedDate = menu.UpdatedDate
            };

            return(result);
        }
Beispiel #2
0
        private Menu ToMenu(MenuDTO menuDTO)
        {
            if (menuDTO == null)
            {
                return(null);
            }

            Menu parent = null;

            if (menuDTO.Parent != null)
            {
                parent = Menu.Create(menuDTO.Parent.Id);
            }

            var result = new Menu(
                menuDTO.Id,
                menuDTO.Text,
                menuDTO.Url,
                menuDTO.Order,
                parent,
                ToDomainObject <Role>(menuDTO.Role),
                ToDomainObjects <Menu>(menuDTO.Children)
                );

            return(result);
        }