public void OnActionExecuting(ActionExecutingContext context)
        {
            if (OnActionExecutingVerbs.HasFlag(HttpVerbMapper.GetVerb(context.HttpContext.Request.Method)))
            {
                IVersioned <IConcurrencyVersion> resource = context.ActionArguments.Values.OfType <IVersioned <IConcurrencyVersion> >().SingleOrDefault();

                if (resource != null)
                {
                    resource.Version = _concurrencyVersionProvider.Get();
                }
            }
        }
 public void OnActionExecuted(ActionExecutedContext context)
 {
     if (OnActionExecutedVerbs.HasFlag(HttpVerbMapper.GetVerb(context.HttpContext.Request.Method)))
     {
         if (context.Result is ObjectResult result)
         {
             if (result.Value is BuiltResource builtResource)
             {
                 if (builtResource.Version != null)
                 {
                     string jsonVersion    = JsonConvert.SerializeObject(builtResource.Version);
                     byte[] plainTextBytes = System.Text.Encoding.UTF8.GetBytes(jsonVersion);
                     context.HttpContext.Response.Headers[ConcurrencyHeaders.ETag] = Convert.ToBase64String(plainTextBytes);
                 }
             }
         }
     }
 }
        public async Task Invoke(HttpContext context, ITransactionManager transactionManager)
        {
            if (TransactionalMethods.HasFlag(HttpVerbMapper.GetVerb(context.Request.Method)))
            {
                using (ITransaction transaction = transactionManager.Create())
                {
                    await _next.Invoke(context);

                    if (SuccesStatusCodes.Contains((HttpStatusCode)context.Response.StatusCode))
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        transaction.Rollback();
                    }
                }
            }
            else
            {
                await _next.Invoke(context);
            }
        }