private static IHttpResponse ToNotFound(
            ExceptionHttpResponseContext configuration,
            EntityNotFoundApiEvent apiEvent)
        {
            var resource   = configuration.Formatter.Resource(apiEvent.EntityType);
            var resourceId = configuration.Formatter.Field(apiEvent.EntityId);

            return(new ResourceNotFoundHttpResponse(
                       $"The {resource} resource with identifier '{resourceId}' was not found.",
                       configuration.Formatter.Code(apiEvent.Code),
                       resource,
                       resourceId));
        }
        private static IHttpResponse ToCreate(
            ExceptionHttpResponseContext configuration,
            EntityCreatedApiEvent apiEvent)
        {
            var resource = configuration.Formatter.Resource(apiEvent.EntityType);

            var message = string.IsNullOrWhiteSpace(apiEvent.EntityId)
                ? $"The user with identifier '{apiEvent.UserId}', created a {resource} resource"
                : $"The user with identifier '{apiEvent.UserId}', created a {resource} resource with resource identifier '{configuration.Formatter.Field(apiEvent.EntityId)}'";

            return(new ResourceCreatedHttpResponse(
                       configuration.Formatter.Message(message),
                       configuration.Formatter.Code(apiEvent.Code),
                       configuration.Formatter.Field(apiEvent.EntityId)));
        }
        private static IHttpResponse ToPermission(
            ExceptionHttpResponseContext configuration,
            EntityPermissionApiEvent apiEvent)
        {
            var userId     = configuration.Formatter.Field(apiEvent.UserId);
            var resource   = configuration.Formatter.Resource(apiEvent.EntityType);
            var resourceId = configuration.Formatter.Field(apiEvent.EntityId);

            var message = $"The user with identifier '{apiEvent.UserId}', does not have permission to access the {resource} resource with identifier '{resourceId}'";

            return(new ResourceAccessPermissionHttpResponse(
                       message,
                       configuration.Formatter.Code(apiEvent.Code),
                       userId,
                       resource,
                       resourceId));
        }