public async Task <IActionResult> Post(string clientId, string key, [FromBody] SetRequestModel model) { if (!_inputValidator.IsValidClientId(clientId)) { return(BadRequest(ResponseModel.CreateWithError(ErrorType.Validation, InvalidClientIdMessage))); } if (!_inputValidator.IsValidKey(key)) { return(BadRequest(ResponseModel.CreateWithError(ErrorType.Validation, InvalidKeyMessage))); } if (!_inputValidator.IsValidPayload(model.Data)) { return(BadRequest(ResponseModel.CreateWithError(ErrorType.Validation, InvalidPayloadMessage))); } if (!_inputValidator.IsValidPayloadSize(model.Data)) { return(BadRequest(ResponseModel.CreateWithError(ErrorType.Validation, TooBigPayloadMessage))); } await _clientDictionary.SetAsync(clientId, key, model.Data); return(Ok(ResponseModel.CreateWithData(null))); }
public async Task <IActionResult> Delete(string clientId, string key) { if (!_inputValidator.IsValidClientId(clientId)) { return(BadRequest(ResponseModel.CreateWithError(ErrorType.Validation, InvalidClientIdMessage))); } if (!_inputValidator.IsValidKey(key)) { return(BadRequest(ResponseModel.CreateWithError(ErrorType.Validation, InvalidKeyMessage))); } try { await _clientDictionary.DeleteAsync(clientId, key); } catch (KeyNotFoundException) { return(NotFound(ResponseModel.CreateWithError(ErrorType.NotFound, null))); } return(Ok(ResponseModel.CreateWithData(null))); }