So if I have this:
public MainMenuModel(string transKey, string stateName, string displayUrl, bool hasSubMenu= false,List<SubMenuModel>subMenu=null)
{
TransKey = transKey;
StateName = stateName;
DisplayUrl = displayUrl;
HasSubMenu = hasSubMenu;
SubMenu = subMenu;
}
public string TransKey { get; set; }
public string StateName { get; set; }
public string DisplayUrl { get; set; }
public bool HasSubMenu { get; set; }
public List<SubMenuModel>SubMenu { get; set; }
}
public class SubMenuModel
{
public SubMenuModel(string transKey, string stateName, string displayUrl)
{
TransKey = transKey;
StateName = stateName;
DisplayUrl = displayUrl;
}
public string TransKey { get; set; }
public string StateName { get; set; }
public string DisplayUrl { get; set; }
}
How can I add SubMenu
in MainMenu
with some condition for example:
if(test!=null)
{
SubMenu.Add(new SubMenuModel("PERSONAL_INFORMATION","account.personalinformation","/account/personalinformation"));
}
SubMenu.Add(new SubMenuModel("NOTIFICATIONS", "account.notificationsettings", "/account/notifications"));
SubMenu.Add(new SubMenuModel("CHANGE_PASSWORD", "account.changepassword", "/account/passwordchange"));
SubMenu.Add(new SubMenuModel("GAME_SETTINGS", "default", "default"));
MainMenu.Add(SubMenu)
--> this is not working...how can I add with condition sub menu in main menu? I tried MainMenu.AddRange(SubMenu)
also but I cant do like that because its different types. I tried something like this :
for (int i = 0; i < SubMenu.Count; i++)
{
MainMenu[0].SubMenu.Add(SubMenu[i]);
}
But I get an error.Any suggestion?