public async Task Update()
        {
            var menuItem = new MenuItemEntityModel
            {
                Header        = _parentMenuItem.Header,
                IsMenuEnabled = SelectedElementInIsMenuEnabled.ToString(),
                Id            = _parentMenuItem.Id
            };
            await _menuItemDataStore.UpdateItemAsync(menuItem, _parentMenuItem.Id);

            MenuItemUpdated?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 2
0
 public async Task Handle(MenuItemUpdated @event)
 {
     await ClearCache(@event.SiteId, @event.Name);
 }
Ejemplo n.º 3
0
        private void Apply(MenuItemUpdated @event)
        {
            var menuItem = MenuItems.FirstOrDefault(x => x.Id == @event.MenuItem.Id);

            menuItem?.Update(@event.MenuItem);
        }
Ejemplo n.º 4
0
 public void Handle(MenuItemUpdated @event)
 {
     ClearCache(@event.SiteId, @event.Name);
 }
Ejemplo n.º 5
0
        public void Setup()
        {
            _menu = new Menu();

            var menuItemId = Guid.NewGuid();

            var addMenuItemCommand = new AddMenuItem
            {
                SiteId                = _menu.SiteId,
                MenuId                = Guid.NewGuid(),
                MenuItemId            = menuItemId,
                MenuItemType          = MenuItemType.Link,
                PageId                = Guid.NewGuid(),
                Link                  = "link",
                Text                  = "Text",
                Title                 = "Title",
                MenuItemLocalisations = new List <MenuItemDetails.MenuItemLocalisation>
                {
                    new MenuItemDetails.MenuItemLocalisation
                    {
                        LanguageId = Guid.NewGuid(),
                        Text       = "Text 1",
                        Title      = "Title 1"
                    },
                    new MenuItemDetails.MenuItemLocalisation
                    {
                        LanguageId = Guid.NewGuid(),
                        Text       = "Text 2",
                        Title      = "Title 2"
                    }
                }
            };

            var addMenuItemValidatorMock = new Mock <IValidator <AddMenuItem> >();

            addMenuItemValidatorMock.Setup(x => x.Validate(addMenuItemCommand)).Returns(new ValidationResult());

            _menu.AddMenuItem(addMenuItemCommand, addMenuItemValidatorMock.Object);

            _command = new UpdateMenuItem
            {
                SiteId                = _menu.SiteId,
                MenuId                = _menu.Id,
                MenuItemId            = menuItemId,
                MenuItemLocalisations = new List <MenuItemDetails.MenuItemLocalisation>
                {
                    new MenuItemDetails.MenuItemLocalisation
                    {
                        LanguageId = Guid.NewGuid(),
                        Text       = "Text 1",
                        Title      = "Title 1"
                    },
                    new MenuItemDetails.MenuItemLocalisation
                    {
                        LanguageId = Guid.NewGuid(),
                        Text       = "Text 2",
                        Title      = "Title 2"
                    }
                }
            };

            _validatorMock = new Mock <IValidator <UpdateMenuItem> >();
            _validatorMock.Setup(x => x.Validate(_command)).Returns(new ValidationResult());

            _menu.UpdateMenuItem(_command, _validatorMock.Object);

            _menuItem = _menu.MenuItems.FirstOrDefault(c => c.Id == _command.MenuItemId);

            _firstMenuItemLocalisation = _menuItem.MenuItemLocalisations.FirstOrDefault();

            _event = _menu.Events.OfType <MenuItemUpdated>().SingleOrDefault();
        }