[HttpPost] //Always explicitly state the accepted HTTP method
        public IHttpActionResult Div([FromBody] RootDivRequest rootRequest)
        {
            double           remainder    = 0;
            ContextOperation context      = new ContextOperation();
            RootDivResponse  rootResponse = new RootDivResponse()
            {
                Quotient  = context.Division(rootRequest.Dividend, rootRequest.Divisor, out remainder),
                Remainder = remainder
            };


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


            return(Ok(rootResponse));
        }
Beispiel #2
0
 public void Test5() => Assert.AreEqual(2, context.Division(10, 5, out result));