public async Task <IActionResult> AsssignRolesToMenu(string id, [FromBody] MenuProfile menuProfile) { _logger.Info("Updating menu profile with app id = {id} and menu profile = {@menuProfile}", id, menuProfile); await _appRepository.UpdateMenuProfileAsync(id, menuProfile); return(Ok()); }
public IMenu CreateMenu(MenuProfile profile) { var type = this.GetMenuObjectType(profile); var menu = (IMenu)this.RecyclePool.Retrieve(type); menu.Prepare(profile, this); menu.UpdatePosition(); menu.ApplyTheme(this.Theme); return(menu); }
public async Task UpdateMenuProfileAsync(string appId, MenuProfile menuProfile) { var app = await _context.Apps.FirstAsync(a => a.Id == appId); if (app.MenuProfiles == null) { app.MenuProfiles = new List <MenuProfile>(); } app.MenuProfiles.Add(menuProfile); _context.SaveChanges(); }
public async Task Update_Menu_Profile_In_Mongo_Test() { if (!_context.AllowMongoDB) { Assert.True(true); return; } // Arrange DatabaseOptions databaseOptions = new DatabaseOptions { ConnectionString = _context.MongoDatabaseConenction.ConnectionString, ConnectionType = ConnectionType.MongoDB, Datasource = _context.MongoDatabaseConenction.DataSource }; IOptionsMonitor <DatabaseOptions> databaseOptionsMock = Mock.Of <IOptionsMonitor <DatabaseOptions> >(_ => _.CurrentValue == databaseOptions); AppMongoRepository appMongoRepository = new AppMongoRepository(new Core.Persistences.MongoConnection(databaseOptionsMock.CurrentValue)); // Act App app = new App { Id = DataUtil.GenerateUniqueId(), Name = "testapp1", DisplayName = "Test App" }; await appMongoRepository.AddAsync(app); List <Menu> menus = new List <Menu> { new Menu { Id = Guid.NewGuid().ToString(), DisplayName = "Core" } }; await appMongoRepository.UpdateMenuAsync(app.Id, menus); MenuProfile menuProfile = new MenuProfile { MenuIds = new List <string> { menus[0].Id }, Role = "Admin" }; await appMongoRepository.UpdateMenuProfileAsync(app.Id, menuProfile); appMongoRepository.Dispose(); // Assert Assert.True(true); }
public async Task Update_Menu_Profile_In_MySql_Test() { if (!_context.AllowMySQL) { Assert.True(true); return; } // Arrange #pragma warning disable CA2000 // Dispose objects before losing scope AppEFRepository appEFRepository = new AppEFRepository(_context.GetMySQLContext()); #pragma warning restore CA2000 // Dispose objects before losing scope // Act App app = new App { Id = DataUtil.GenerateUniqueId(), Name = "testapp1", DisplayName = "Test App" }; await appEFRepository.AddAsync(app); List <Menu> menus = new List <Menu> { new Menu { Id = Guid.NewGuid().ToString(), DisplayName = "Core" } }; await appEFRepository.UpdateMenuAsync(app.Id, menus); MenuProfile menuProfile = new MenuProfile { MenuIds = new List <string> { menus[0].Id }, Role = "Admin" }; await appEFRepository.UpdateMenuProfileAsync(app.Id, menuProfile); appEFRepository.Dispose(); // Assert Assert.True(true); }
public MenuProfile GenerateMenuProfile() { var menu = new MenuProfile("GHF_CharacterMenu", 400, () => { }) { height = 360, theme = MenuThemeType.TabTheme, onHide = this.onHide, title = "Gryphonheart Flags - My profile", icon = "Interface\\Icons\\Spell_Misc_EmotionHappy", }; foreach (var page in this.pages) { menu.Add(page); } return(menu); }
public async Task UpdateMenuProfileAsync(string appId, MenuProfile menuProfile) { var app = await GetOneAsync(appId); if (app.MenuProfiles.Any(a => a.Role == menuProfile.Role)) { foreach (var menu in app.MenuProfiles) { if (menuProfile.Role == menuProfile.Role) { menuProfile.MenuIds = menuProfile.MenuIds; break; } } } else { app.MenuProfiles.Add(menuProfile); } await UpdateAsync(app.Id, app); }
private Type GetMenuObjectType(MenuProfile profile) { switch (profile.theme) { case MenuThemeType.StdTheme: return(typeof(WindowedMenu)); case MenuThemeType.BlankTheme: if (profile.useWindow) { return(typeof(WindowedMenu)); } return(typeof(BaseMenu)); case MenuThemeType.TabTheme: return(typeof(TabMenu)); case MenuThemeType.BlankWizardTheme: throw new NotImplementedException(); default: throw new Exception("Unknown theme: " + profile.theme); } }