public async Task <IActionResult> Edit(int id, [Bind("Id,CreationTime,Message")] LogEntry logEntry) { if (id != logEntry.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(logEntry); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LogEntryExists(logEntry.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(logEntry)); }
public async Task <IActionResult> Create([Bind("Name,Birthday,IsMale,Request")] User user) { try { if (ModelState.IsValid) { _context.Add(user); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex */) { //Log the error (uncomment ex variable name and write a log. ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); } return(View(user)); }