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(); }
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)); }
public void Add(NewsIndexListingModel news) { _appDbContext.News.Add(news); _appDbContext.SaveChanges(); }