예제 #1
0
        public async Task <IActionResult> PublichChanges(PublishImpactChangesRequest request)
        {
            var(response, error) =
                await _retryFacility.RetryAsync(
                    operationName : "PublishChanges",
                    action : () => _service.PublishImpactChangesAsync(request));

            if (!error.IsSuccessful())
            {
                return(error.ToActionResult());
            }
            return(Ok(response));
        }
예제 #2
0
        public async Task <ActionResult> Insert()
        {
            string jsonStr;

            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
            {
                jsonStr = await reader.ReadToEndAsync();
            }
            List <TestCaseRequest> testCaseRequests;

            try
            {
                if (jsonStr.StartsWith("["))
                {
                    testCaseRequests = JsonConvert.DeserializeObject <List <TestCaseRequest> >(jsonStr);
                }
                else if (jsonStr.StartsWith("{"))
                {
                    testCaseRequests = new List <TestCaseRequest>()
                    {
                        JsonConvert.DeserializeObject <TestCaseRequest>(jsonStr)
                    }
                }
                ;
                else
                {
                    return(BadRequest("Please post a valid JSON object."));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            var responses = await _retryFacility.RetryAsync(
                operationName : "InsertTestCases",
                action : () => _service.InsertAsync(testCaseRequests));

            if (responses.Count == 1)
            {
                return(CreatedAtAction(nameof(Get), new { id = responses[0].Id }, responses[0]));
            }
            else
            {
                return(Ok());
            }
        }