Example #1
0
 protected virtual Content CreateContent(Content content)
 {
     using (var dbContext = GetDbContext())
     {
         var savedContent = new Content { ID = GetNextContentId(dbContext) };
         dbContext.ContentsSet.Add(savedContent);
         savedContent.CopyPropertiesFrom(content);
         return savedContent;
     }
 }
Example #2
0
 public void CopyPropertiesFrom(Content entity)
 {
     this.ContentText = entity.ContentText;
     this.AuthorID = entity.AuthorID;
     this.CampaignID = entity.CampaignID;
 }
Example #3
0
 protected virtual Content UpdateContent(Content content)
 {
     using (var dbContext = GetDbContext())
     {
         var savedContent = dbContext.ContentsSet.Single(cnt => cnt.ID == content.ID);
         savedContent.CopyPropertiesFrom(content);
         return savedContent;
     }
 }
Example #4
0
 public Content CreateOrUpdateContent(Content content)
 {
     return content.IsNewEntity ? CreateContent(content) : UpdateContent(content);
 }