public ClubRepository(ClubSystemDbContext context) : base(context) { _context = context; var config = new MapperConfiguration(cfg => { cfg.AddProfile <ClubProfile>(); }); _mapper = config.CreateMapper(); }
private async Task <(string userId, ClubResource addedClub1, ClubResource addedClub2)> SetUpPostFeed( ClubSystemDbContext dbContext) { var clubRepository = new ClubRepository(dbContext); var clubDto1 = new ClubDto { Name = "Name1", UniversityName = "University1" }; var clubDto2 = new ClubDto { Name = "Name2", UniversityName = "University2" }; var addedClub1 = clubRepository.AddClub(clubDto1); var addedClub2 = clubRepository.AddClub(clubDto2); const string userId = "1234"; var claimsPrincipal = GenerateClaimsPrincipalWithId(userId); var addUserToClubDto1 = new AddUserToClubDto { ClubId = addedClub1.Id }; var addUserToClubDto2 = new AddUserToClubDto { ClubId = addedClub2.Id }; await clubRepository.AddUserToClub(addUserToClubDto1, claimsPrincipal); await clubRepository.AddUserToClub(addUserToClubDto2, claimsPrincipal); return(userId, addedClub1, addedClub2); }
private IPostRepository GetInMemoryPostRepository() { var builder = new DbContextOptionsBuilder <ClubSystemDbContext>(); var options = builder.UseInMemoryDatabase(new Guid().ToString()).Options; ClubSystemDbContext clubSystemDbContext = new ClubSystemDbContext(options); clubSystemDbContext.Database.EnsureDeleted(); clubSystemDbContext.Database.EnsureCreated(); return(new PostRepository(clubSystemDbContext)); }
// TODO: make generic repository provider with InMemoryDatabase public Repository <T> GetRepositoryWithInMemoryDatabase() { DbContextOptions <ClubSystemDbContext> options; var builder = new DbContextOptionsBuilder <ClubSystemDbContext>(); options = builder.UseInMemoryDatabase(new Guid().ToString()).Options; ClubSystemDbContext clubSystemDbContext = new ClubSystemDbContext(options); clubSystemDbContext.Database.EnsureDeleted(); clubSystemDbContext.Database.EnsureCreated(); return(new Repository <T>(clubSystemDbContext)); }
private ClubSystemDbContext GetInMemoryDbContext() { var builder = new DbContextOptionsBuilder <ClubSystemDbContext>(); var options = builder.UseInMemoryDatabase(new Guid().ToString()).Options; ClubSystemDbContext clubSystemDbContext = new ClubSystemDbContext(options); clubSystemDbContext.Database.EnsureDeleted(); clubSystemDbContext.Database.EnsureCreated(); clubSystemDbContext.Users.Add(new User { Id = "1234", UserName = "******", PasswordHash = new Guid().ToString() }); return(clubSystemDbContext); }
public UserRepository(ClubSystemDbContext context) : base(context) { _context = context; }