コード例 #1
0
        public async Task Invoke(HttpContext context, RoulleteDbContext dbContext)
        {
            var userId            = context.User.Identity.IsAuthenticated ? context.User.GetUserIdFromPrincipal() : string.Empty;
            var ipAddress         = context.Connection.RemoteIpAddress;
            var ipAddressToString = ipAddress.ToString();

            var request = await FormatRequestAsync(context.Request);

            var log = new RequestLog(userId, ipAddressToString, request);

            await dbContext.RequestLogs.AddAsync(log);

            await dbContext.SaveChangesAsync();

            await _next(context);
        }
コード例 #2
0
 public virtual async Task <int> SaveChangesAsync()
 {
     return(await _context.SaveChangesAsync());
 }