Skip to content

Instantly share code, notes, and snippets.

@rofr
Created September 17, 2014 04:13
Show Gist options
  • Save rofr/b4b3e4eababf619cf30b to your computer and use it in GitHub Desktop.
Save rofr/b4b3e4eababf619cf30b to your computer and use it in GitHub Desktop.
Building a CMS with OrigoDB - snippet 7
[Serializable]
public class RemoveMenuCommand : Command<CmsModel>
{
public readonly string MenuName;
public RemoveMenuCommand(string menuName)
{
MenuName = menuName;
}
protected override void Execute(CmsModel model)
{
try
{
model.RemoveMenu(MenuName);
}
catch (InvalidOperationException)
{
throw new CommandFailedException("Cant delete menu, no such name:" + MenuName);
}
}
}
[Serializable]
public class PutMenuCommand : Command<CmsModel>
{
public readonly Menu Menu;
public PutMenuCommand(Menu menu)
{
if (menu == null)
throw new ArgumentNullException("menu");
Menu = menu;
}
protected override void Execute(CmsModel model)
{
model.PutMenu(Menu);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment