Example #1
0
File: NewsVm.cs Project: Saphora/FC
 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;
 }
Example #2
0
 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);
     }
 }
Example #3
0
 public void Update(UNews news)
 {
     Db.Entry<UNews>(news).State = System.Data.Entity.EntityState.Modified;
     Db.SaveChanges();
 }
Example #4
0
 public void Create(UNews news)
 {
     news.NewsID = news.NewsID;
     Db.News.Add(news);
     Db.SaveChanges();
 }