public bool CreateNews(News instance) { if (instance.ID == 0) { Db.News.InsertOnSubmit(instance); Db.News.Context.SubmitChanges(); return true; } return false; }
public bool UpdateNews(News instance) { News cache = Db.News.Where(p => p.ID == instance.ID).FirstOrDefault(); if (cache != null) { cache.TitleNew = instance.TitleNew; cache.TextNew = instance.TextNew; cache.PreviewText = instance.PreviewText; cache.PictureNew = instance.PictureNew; cache.DateNew = instance.DateNew; cache.OtherInfo = instance.OtherInfo; Db.News.Context.SubmitChanges(); return true; } return false; }
partial void DeleteNews(News instance);
partial void UpdateNews(News instance);
partial void InsertNews(News instance);
public PartialViewResult GetNews(News news) { var ne = ModelMapper.Map(Repository.AllNews.Take(3).OrderByDescending(s => s.DateNew).ToList(), typeof(List<News>), typeof(IEnumerable<NewsModel>)); return PartialView(ne); }