public async Task <IActionResult> Edit(int id, [Bind("Name,ID,Date,Day,Symptoms,Body")] JournalModel journal) { if (id != journal.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(journal); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JournalExists(journal.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(journal)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,FirstName,LastName")] User user) { if (id != user.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { //if (!UserExists(user.Id)) //{ // return NotFound(); //} //else //{ // throw; //} } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,DateTime,Document")] Conversation conversation) { if (id != conversation.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(conversation); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ConversationExists(conversation.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(conversation)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Author,IsPrivate")] Coach coach) { if (id != coach.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(coach); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CoachExists(coach.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(coach)); }
public async Task <IActionResult> Edit( [FromServices] IMemoryCache cache, Journal journal, CancellationToken requestAborted) { if (ModelState.IsValid) { _context.Update(journal); await _context.SaveChangesAsync(requestAborted); //Invalidate the cache entry as it is modified cache.Remove(GetCacheKey(journal.JournalId)); return(RedirectToAction("Index")); } ViewBag.CategoryId = new SelectList(_context.Categories, "CategoryId", "Name", journal.CategoryId); ViewBag.PublisherId = new SelectList(_context.Publishers, "PublisherId", "Name", journal.Publisher.PublisherId); return(View(Mapper.Map <JournalViewModel>(journal))); }