Exemplo n.º 1
0
        protected async Task <ActionResult> Configure(ResourceHandlerConfiguration configuration)
        {
            await configuration.Task;

            return(StatusCode((int)HttpStatusCode.OK,
                              $"{configuration.DelayInMs} milliseconds delay is saved, {configuration.HttpStatusCode} HttpStatusCode is saved,{configuration.InvalidToken} token is saved"));
        }
        protected async Task AddResourceConfig(object data, ResourceHandlerConfiguration resourceHandlerConfigurations)
        {
            var json       = JsonConvert.SerializeObject(data);
            var configData = new ResourceConfigData
            {
                Hash         = json.GetMd5Hash(), DelayInMs = resourceHandlerConfigurations.DelayInMs, HttpStatusCode = resourceHandlerConfigurations.HttpStatusCode,
                InvalidToken = resourceHandlerConfigurations.InvalidToken, Body = json
            };

            await using var context = new RelayApiContext(Options);
            await context.ResourceConfigData.AddAsync(configData).ConfigureAwait(false);

            await context.SaveChangesAsync().ConfigureAwait(false);
        }