public async Task <IActionResult> Edit(string id, [Bind("AwsInstanceID,Region,InstanceState")] AwsInstance awsInstance) { if (id != awsInstance.AwsInstanceID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(awsInstance); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AwsInstanceExists(awsInstance.AwsInstanceID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(awsInstance)); }
public async Task <IActionResult> Put(int id, [FromBody] User userUpdateValue) { try { userUpdateValue.EntryTime = DateTime.Now; var userToEdit = await _context.User .AsNoTracking() .SingleOrDefaultAsync(m => m.ID == id); if (userToEdit == null) { return(NotFound("Could not update user as it was not Found")); } else { _context.Update(userUpdateValue); await _context.SaveChangesAsync(); return(Ok("Updated user - " + userUpdateValue.Name)); } } catch (DbUpdateException) { //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(NotFound("User not Found")); } }