public static RequestLogCreation CreationToDomainModel(this RequestLogCreationModel @this) { return(new RequestLogCreation { Body = @this.Body, Ip = @this.Ip, Uri = @this.Uri, HttpMethod = @this.HttpMethod }); }
public override Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken) { lock (_lockObject) { string rawRequest; using (var stream = new StreamReader(actionContext.Request.Content.ReadAsStreamAsync().Result)) { stream.BaseStream.Position = 0; rawRequest = stream.ReadToEnd(); } RequestLogCreationModel model = new RequestLogCreationModel { Uri = actionContext.Request.RequestUri.AbsoluteUri, Body = rawRequest, Ip = GetClientIpAddress(actionContext.Request), HttpMethod = actionContext.Request.Method.Method }; _requestLoggingService.AddRow(model.CreationToDomainModel()); } return(Task.CompletedTask); }