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