[HttpPost] //Always explicitly state the accepted HTTP method
        public IHttpActionResult Sub([FromBody] RootSubRequest rootRequest)
        {
            ContextOperation context      = new ContextOperation();
            RootSubResponse  rootResponse = new RootSubResponse()
            {
                Difference = context.Diff(rootRequest.Minuend, rootRequest.Subtrahend)
            };


            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 = (rootRequest.Minuend + context.BinaryOperationStrategy.OperatorCode + rootRequest.Subtrahend) + "=" + rootResponse.Difference,
                    Id          = XEviTrackingId,
                    Date        = DateTime.Now,
                    Operation   = context.BinaryOperationStrategy.Name
                };
                this.journalDBOperations.PersistOperation(operation);
            }

            return(Ok(rootResponse));
        }
Beispiel #2
0
 public void Test4() => Assert.AreEqual(-1, context.Diff(4, 5));