[HttpPost] //Always explicitly state the accepted HTTP method
        public IHttpActionResult Sqrt([FromBody] RootSqrtRequest rootRequest)
        {
            ContextOperation context      = new ContextOperation();
            RootSqrtResponse rootResponse = new RootSqrtResponse()
            {
                Square = context.Square(rootRequest.Number),
            };

            System.Net.Http.Headers.HttpRequestHeaders headers = this.Request.Headers;
            string XEviTrackingId = string.Empty;

            if (headers.Contains("XEviTrackingId"))
            {
                XEviTrackingId = headers.GetValues("XEviTrackingId").FirstOrDefault();

                OperationDTO operation = new OperationDTO()
                {
                    Calculation = (context.UnaryOperationStrategy.OperatorCode + rootRequest.Number) + "=" + rootResponse.Square,
                    Id          = XEviTrackingId,
                    Date        = DateTime.Now,
                    Operation   = context.UnaryOperationStrategy.Name
                };
                this.journalDBOperations.PersistOperation(operation);
            }

            return(Ok(rootResponse));
        }
Example #2
0
 public void Test1() => Assert.AreEqual(4, context.Square(16));