public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, CadCliDataContext dataContext) { loggerFactory.AddConsole(); app.UseExceptionHandler(appBuilder => { appBuilder.Use(async(context, next) => { var error = context.Features[typeof(IExceptionHandlerFeature)] as IExceptionHandlerFeature; if (error != null && error.Error is SecurityTokenExpiredException) { context.Response.StatusCode = 401; context.Response.ContentType = "application/json"; await context.Response.WriteAsync( JsonConvert.SerializeObject( new { authenticated = false, tokenExpired = true })); } else if (error != null && error.Error != null) { context.Response.StatusCode = 500; context.Response.ContentType = "application/json"; await context.Response.WriteAsync( JsonConvert.SerializeObject (new { success = false, error = error.Error.Message })); } else { await next(); } }); }); app.UseJwtBearerAuthentication(new JwtBearerOptions { TokenValidationParameters = new TokenValidationParameters { IssuerSigningKey = _key, ValidAudience = _tokenOptions.Audience, ValidIssuer = _tokenOptions.Issuer, ValidateLifetime = true, ClockSkew = TimeSpan.FromMinutes(0) } }); app.UseCors(options => { options.AllowAnyHeader(); options.AllowAnyMethod(); options.AllowAnyOrigin(); }); app.UseMvc(); DbInitializer.Initialize(dataContext); app.Run(async(context) => { context.Response.StatusCode = (int)HttpStatusCode.NotFound; await context.Response.WriteAsync("Recurso não encontrado!"); }); }
public ClienteRepository(CadCliDataContext context) : base(context) { }
public UsuarioRepository(CadCliDataContext context) : base(context) { }
public ClientesController(CadCliDataContext ctx) { _ctx = ctx; }
public ClienteRepository(CadCliDataContext ctx) : base(ctx) => _db = ctx.Set <Cliente>();
public Repository(CadCliDataContext context) { _context = context; }
public Repository(CadCliDataContext ctx) => _ctx = ctx;