public static bool IsNotModified(this HttpRequestMessage requestMessage, IHaveVersion versionable) { if (!requestMessage.Headers.IfNoneMatch.Any()) return false; var etag = requestMessage.Headers.IfNoneMatch.First().Tag; return string.Format("\"{0}\"", versionable.Version) == etag; }
private static int UpdateVersion(IHaveVersion item, int defaultVersion) => item?.Version + 1 ?? defaultVersion;