miketindi@hotmail.com's picture
Dec 18, 2015
1986 views
Reputation: 2

help building an extension

Hi, I am building an extension to this system but having trouble creating Menu categories dynamically. I am using the following pieces of code.

foreach (string aCategory in categories) { // The Category View model . add aCategory  ScreenMenuCategory aNewCategoryModel = new ScreenMenuCategory(); aNewCategoryModel.Name = aCategory; aNewCategoryModel.ScreenMenuId = aMenu.Model.Id; Dao.RemoveFromCache(aNewCategoryModel as ICacheable); _workspace.Update(aNewCategoryModel); _workspace.CommitChanges();

 

And I have also tried the following.

EntityCollectionViewModelBase allMenuItems = new EntityCollectionViewModelBase(); ERPScreenMenuViewModel aMenu = new ERPScreenMenuViewModel(); // aMenuCollection.GetMainMenu(); aMenu = allMenuItems.Items[0]; aMenu.Categories.Add(new ScreenMenuCategoryViewModel(new ScreenMenuCategory(aCategory)));

//aMenu.Save();

Dao.RemoveFromCache(aMenu.Model as ICacheable);

_workspace.Update(aMenu.Model);

_workspace.CommitChanges();

What could be the problem? I am using the same _workspase.Update and commitChanges to create MenuItems but its the Categories that are not getting created. Are there any business rules that are preventing it from getting created?

We have already answers to
1029 questions
E-Posta Facebook Twitter RSS Skype
Telefon (212) 252 0634