builder.ConfigureTestServices(services => { services.RemoveJwtAuthentication(); services.Configure<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme, options => { SecurityKey issuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("9f7b309b-1dcc-4a96-a292-dbe6e830d8c3")); options.TokenValidationParameters = new TokenValidationParameters { ValidIssuer = "TestIssuer", ValidAudience = "TestAudience", ValidateIssuer = true, ValidateLifetime = true, ValidateIssuerSigningKey = true, ClockSkew = TimeSpan.Zero, IssuerSigningKey = issuerSigningKey }; } ); services.RemoveDbContext<JobbyDbContext>(); services.AddDbContext<JobbyDbContext>(options => { options.UseSqlServer(_mssqlContainer.GetConnectionString()); }); });
public static void RemoveDbContext<T>(this IServiceCollection services) where T : DbContext { var dbContextOptionsService = services.SingleOrDefault( d => d.ServiceType == typeof(DbContextOptions<T>)); if (dbContextOptionsService != null) { services.Remove(dbContextOptionsService); } var dbContextService = services.SingleOrDefault(d => d.ServiceType == typeof(T)); if (dbContextService != null) { services.Remove(dbContextService); } }
public sealed class GetJobContactsSpecification : Specification<Contact>{ public GetJobContactsSpecification(Guid jobId, string userId) { Query .Include(x => x.Companies) .Include(x => x.Phones) .Include(x => x.Emails) .AsSplitQuery() .AsNoTracking() .Where(contact=> contact.Jobs.Any(job => job.Id == jobId && job.OwnerId == userId)); }}
[HttpGet("Search/{value}")] public async Task<IActionResult> Search(string value) { var response = await _mediator.Send( new SearchStudentAbsencesQuery( value ) ); var model = _mapper.Map<List<StudentAbsenceIndexVm>>( response.Entities ); ViewBag.SearchValue = value; return View( model ); }