コード例 #1
0
        public void GetGWPDataPositiveTest()
        {
            GWPModel gWPModel = new GWPModel();

            gWPModel.Country = "ae";
            gWPModel.LOB     = "transport,freight";
            CountryGWPController ec = new CountryGWPController(logger, gwpService.Object);
            var res = ec.Post(gWPModel).Result as OkObjectResult;

            gwpService.Verify();
            Assert.AreEqual(res.StatusCode.Value, StatusCodes.Status200OK);
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] GWPModel gwpModel)
        {
            try
            {
                if (gwpModel == null)
                {
                    return(BadRequest("Data is in incorect format"));
                }
                logger.LogInformation(String.Format("Calculating response for Country: {0} and LOB: {1}", gwpModel.Country, gwpModel.LOB));
                Dictionary <string, double> res = await gwpService.GetGWPDataResponse(gwpModel.Country, gwpModel.LOB.Split(new char[] { ',' }));

                if (res == null)
                {
                    return(NotFound(String.Format("Data not found for reuest with  Country: {0} and LOB: {1}", gwpModel.Country, gwpModel.LOB)));
                }
                return(Ok(res));
            }
            catch (Exception ex)
            {
                logger.LogError(String.Format("Error occured with message {0}. Stack Trace {1}", ex.Message, ex.StackTrace));
                return(StatusCode(500, String.Format("Unable to process the request. \nException : {0}", ex.Message)));
            }
        }