public async Task <IActionResult> PutCharacterModel([FromRoute] int id, [FromBody] CharacterModel characterModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != characterModel.Id) { return(BadRequest()); } _context.Entry(characterModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CharacterModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutUserInfoModel([FromRoute] string id, [FromBody] UserInfoModel userInfoModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userInfoModel.Username) { return(BadRequest()); } var userFromDb = await _context.UserInfoModel.FindAsync(userInfoModel.Username); if (BCrypt.Net.BCrypt.EnhancedVerify(userInfoModel.Password, userFromDb.Password)) { _context.Entry(userInfoModel).State = EntityState.Modified; } else { return(Unauthorized()); } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserInfoModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }