public NewsVm(UNews data) { this.UmbracoID = data.UmbracoID; this.Title = data.Title; this.Content = data.Text; this.DisplayDate = data.DisplayDate; this.GenreID = data.Genres[0].UmbracoID.ToString(); this.Type = data.Type; this.Img = data.Img; this.Link = "/#/News/" + data.UmbracoID + "/"+this.GenreID; this.SortDate = data.Date; }
public SeedNews(string versionID, ContentModel db, UmbracoProvider provider) : base(versionID, db, provider) { SeedName = "News"; SeedStart(); if (SeedCanRun) { List<UNews> results = UProvider.GetList<UNews>("News").ToList(); if (results.Count > 0) { foreach (UNews r in results) { UNews tmp = new UNews(r); if (!Db.News.Where(w => w.UmbracoID == tmp.UmbracoID).Any()) { tmp.NewsID = Guid.NewGuid(); tmp.Genres = null; Db.News.Add(tmp); } } } try { Db.SaveChanges(); SeedFinished(true); } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { HandleDbEntityValidationException(ex); throw ex; } } else { SeedFinished(true); } }
public void Update(UNews news) { Db.Entry<UNews>(news).State = System.Data.Entity.EntityState.Modified; Db.SaveChanges(); }
public void Create(UNews news) { news.NewsID = news.NewsID; Db.News.Add(news); Db.SaveChanges(); }