public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Description")] Article article) { if (id != article.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(article); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ArticleExists(article.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(article)); }
public async Task <IActionResult> Edit(int id, [Bind("MenuId,MenuName")] Menu menu) { if (id != menu.MenuId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(menu); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MenuExists(menu.MenuId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(menu)); }
public async Task <ActionResult> EditArticle(Article article, IFormFile articleImage) { // TypeArticle.GamblingAddiction.GetDisplayName(); if (ModelState.IsValid) { await _articleContext.Update(article); if (articleImage != null) { using (var memoryStream = new MemoryStream()) { await articleImage.CopyToAsync(memoryStream); if (articleImage != null) { await _articleContext.StoreImage(article.Id, memoryStream.ToArray(), articleImage.FileName); } } } return(RedirectToAction("Index")); } return(View(article)); }