コード例 #1
0
        /// <summary>
        /// 执行拦截
        /// </summary>
        /// <param name="context"></param>
        /// <param name="next"></param>
        /// <returns></returns>
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            var executedContext = await next();

            if (executedContext.Exception == null)
            {
                await _uow.CommitAsync();
            }
        }
コード例 #2
0
 /// <summary>
 /// 请求完成后提交工作单元中的当前工作
 /// </summary>
 /// <param name="actionExecutedContext"></param>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public Task OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)
 {
     if (actionExecutedContext.Exception == null && actionExecutedContext.Response.IsSuccessStatusCode == true)
     {
         return(_uow.CommitAsync());
     }
     else
     {
         return(Task.FromResult(0));
     }
 }