public ActionResult EditNews(EditNewsRequestDTO dto) { string url = "api/News/EditNews"; enErrorCode result = _apiAdaptor.Post <EditNewsRequestDTO, enErrorCode>(url, dto); return(RedirectToAction("BackEndIndex", "News")); }
public ActionResult EditNews(int NewsId) { string url = String.Format("api/News/GetNewsContent?NewsID={0}", NewsId); GetNewsContentReturnDTO result = _apiAdaptor.Get <GetNewsContentReturnDTO>(url); EditNewsRequestDTO dto = new EditNewsRequestDTO() { NewsID = NewsId, Title = result.NewsTitle, Category = result.NewsCategory, NewsContent = result.NewsContent }; return(View(dto)); }
public enErrorCode EditNews(EditNewsRequestDTO dto) { enErrorCode enCode = enErrorCode.EXCEPTION; try { News n = _dbContext.Set <News>().Find(dto.NewsID); n.Title = dto.Title; n.Category = dto.Category.ToString(); n.NewsContent = dto.NewsContent; int result = _dbContext.SaveChanges(); if (result == 1) { enCode = enErrorCode.SUCCESS; } } catch (Exception ex) { throw; } return(enCode); }