static private Core.Models.Content.ContentItem Create(Core.Models.Content.ContentItem content, DataModel.Entities db) { var newContent = new DataModel.Content() { Id = content.Id, Title = content.Title, Description = content.Description, Url = content.Url, Body = content.Body, ContentDate = content.ContentDate, CategoryId = content.CategoryId, UserId = content.UserId, Type = content.Type, Status = content.Status, Created = DateTime.Now }; db.Contents.Add(newContent); db.SaveChanges(); return(content); }
static private Core.Models.Content.ContentItem Update(Core.Models.Content.ContentItem content, DataModel.Entities db, DataModel.Content dbContent) { dbContent.Title = !string.IsNullOrEmpty(content.Title) && content.Title != dbContent.Title ? content.Title : dbContent.Title; dbContent.Body = !string.IsNullOrEmpty(content.Body) && content.Body != dbContent.Body ? content.Body : dbContent.Body; dbContent.CategoryId = content.CategoryId != null && content.CategoryId != dbContent.CategoryId ? content.CategoryId : dbContent.CategoryId; dbContent.UserId = content.UserId != null && content.UserId != dbContent.UserId ? content.UserId : dbContent.UserId; dbContent.Type = content.Type != dbContent.Type ? content.Type : dbContent.Type; dbContent.Status = content.Status != dbContent.Status ? content.Status : dbContent.Status; db.SaveChanges(); return(content); }