public async Task <IActionResult> PutTornApiKey(int id, TornApiKey tornApiKey) { if (id != tornApiKey.PlayerId) { return(BadRequest()); } _context.Entry(tornApiKey).State = EntityState.Modified; try { await _context.SaveChangesAsync().ConfigureAwait(false); } catch (DbUpdateConcurrencyException ex) { _logger.LogError(ex, "Error attempting to PUT {0}", id); if (!TornApiKeyExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("ApiKey,Enabled,TrackPlayer,TrackFaction,TrackCompany,TrackTorn")] TornApiKey tornApiKey) { if (ModelState.IsValid) { // Verify API Key tornApiKey = await VerifyApiKey(tornApiKey).ConfigureAwait(false); _context.Add(tornApiKey); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tornApiKey)); }