示例#1
0
        public void Edit(int id, NewsIndexListingModel request)
        {
            var result = _appDbContext.News.Where(x => x.Id == id);

            var entity = result.FirstOrDefault();

            _appDbContext.News.Attach(entity);
            _appDbContext.News.Update(entity);

            _appDbContext.SaveChanges();
        }
示例#2
0
 public IActionResult Upsert(int?id)
 {
     News = new NewsIndexListingModel();
     if (id == null)
     {
         //create
         return(View(News));
     }
     //update
     News = _db.News.FirstOrDefault(u => u.Id == id);
     if (News == null)
     {
         return(NotFound());
     }
     return(View(News));
 }
示例#3
0
 public void Add(NewsIndexListingModel news)
 {
     _appDbContext.News.Add(news);
     _appDbContext.SaveChanges();
 }