Created
September 17, 2014 04:11
-
-
Save rofr/ca9a57cd79ed8ee4e1ba to your computer and use it in GitHub Desktop.
Building a CMS with OrigoDB - snippet 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Serializable] | |
| public class CmsModel : Model | |
| { | |
| private IDictionary<Guid, Page> _pages; | |
| private Dictionary<string, Menu> _menus; | |
| public CmsModel() | |
| { | |
| _pages = new Dictionary<Guid, Page>(); | |
| _menus = new Dictionary<string, Menu>(); | |
| } | |
| protected override void SnapshotRestored() | |
| { | |
| if (_menus == null) _menus = new Dictionary<string, Menu>(); | |
| } | |
| public void PutMenu(Menu menu) | |
| { | |
| _menus[menu.Name] = menu; | |
| } | |
| public void RemoveMenu(string name) | |
| { | |
| if (!_menus.ContainsKey(name)) | |
| throw new InvalidOperationException("Cant remove menu, no menu named " + name); | |
| _menus.Remove(name); | |
| } | |
| public void RemovePage(Guid pageId) | |
| { | |
| if (!_pages.ContainsKey(pageId)) | |
| throw new InvalidOperationException("Can't remove page, no page with id " + pageId.ToString()); | |
| _pages.Remove(pageId); | |
| } | |
| public void PutPage(Page page) | |
| { | |
| _pages[page.Id] = page; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment