Esempio n. 1
0
File: Dal.cs Progetto: saegen/moose
 public static void updateContent(string elementId, string content)
 {
     if (string.IsNullOrWhiteSpace(elementId))
     {
         throw new ArgumentNullException("elementId");
     }
     using (DataModel db = new DataModel())
     {
         var _content = db.Content.Find(elementId);
         if (_content == null )
         {
             throw new ArgumentException("could not find {0}", elementId);
         }
         _content.Content = content;
         db.SaveChanges();
     }
 }
Esempio n. 2
0
File: Dal.cs Progetto: saegen/moose
 public static void addContent(string elementId, string content, string url = "")
 {
     if (string.IsNullOrWhiteSpace(elementId))
     {
         throw new ArgumentNullException("elementId");
     }
     using (DataModel db = new DataModel())
     {
         var _content = db.Content.Find(elementId);
         if (_content != null)
         {
             throw new ArgumentException("{0} already exists. Try updateContent?", elementId);
         }
         var contentToSave = new DataLib.Models.EditableContent();
         contentToSave.ElementId = elementId;
         contentToSave.Content = content;
         contentToSave.View = url;
         db.Content.Add(contentToSave);
         db.SaveChanges();
     }
 }