public async Task <IActionResult> Edit(int id, [Bind("ID,webSectionID,UploadID,Title,Body,Caption,sOrder,featuredCode,newsDate,startOn,endOn,isGlobal")] NEWs nEWs) { if (id != nEWs.NewsID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(nEWs); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NEWsExists(nEWs.NewsID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(nEWs)); }
public async Task <IActionResult> CreateorEdit([Bind("NewsID,webSectionID,UploadID,Title,Body,Caption,sOrder,featuredCode,newsDate,startOn,endOn,isGlobal")] NEWs nEWs) { if (ModelState.IsValid) { //_context.Add(nEWs); if (nEWs.NewsID == 0) { int newsResult = _context.Database.ExecuteSqlCommand("PTP_createNews @p0,@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10", nEWs.webSectionID, nEWs.UploadID, nEWs.Title, nEWs.Body, nEWs.Caption, nEWs.sOrder, nEWs.featuredCode, nEWs.newsDate, nEWs.startOn, nEWs.endOn, nEWs.isGlobal); } else { int newsResult = _context.Database.ExecuteSqlCommand("PTP_updateNews @p0,@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11", nEWs.NewsID, nEWs.webSectionID, nEWs.UploadID, nEWs.Title, nEWs.Body, nEWs.Caption, nEWs.sOrder, nEWs.featuredCode, nEWs.newsDate, nEWs.startOn, nEWs.endOn, nEWs.isGlobal); } //await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(nEWs)); }