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