public async Task <IActionResult> CreateOrderTaxStatusAsync([FromBody] OrderTaxStatusViewModel value) { var response = new SingleModelResponse <OrderTaxStatusViewModel>() as ISingleModelResponse <OrderTaxStatusViewModel>; try { var entity = await Task.Run(() => { return(_RESTfulAPI_Repository.AddOrderTaxStatus(value.ToEntity())); }); if (response.DidError == false) { response.Model = entity.ToViewModel(); } } catch (Exception ex) { string webRoot = _hostingEnvironment.WebRootPath; string errorGuid = String.Format(Guid.NewGuid().ToString().Replace("-", string.Empty).Substring(0, 16)); HttpContext.Session.SetString("ErrorGuid", errorGuid); ViewBag.ErrorGuid = HttpContext.Session.GetString("ErrorGuid"); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { using (StreamWriter w = new StreamWriter(webRoot + "\\log.txt", append: true)) { Log.Logging(ex.ToString(), w, ViewBag.ErrorGuid); } } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { using (StreamWriter w = new StreamWriter(webRoot + "/log.txt", append: true)) { Log.Logging(ex.ToString(), w, ViewBag.ErrorGuid); } } response.DidError = true; //response.ErrorMessage = ex.ToString(); return(this.Json(new { timestamp = DateTime.Now, errorGuid = ViewBag.ErrorGuid, status = HttpStatusCode.InternalServerError, info = "Error logged in log file." })); } response.Info = "Client " + " " + HttpContext.Connection.RemoteIpAddress.ToString(); return(response.ToHttpResponse()); }