public void MakeAllActive() { using var context = new WebApiContext(DbContextOptions); var activeState = context.GetActiveState(); foreach (var user in context.Users) { user.StateId = activeState.Id; context.Entry(user).State = EntityState.Modified; } context.SaveChanges(); }
protected UsersControllerTests() { _seeder = new T(); var host = Program.CreateHostBuilder(new string[] { }).Build(); _mapper = host.Services.GetRequiredService <IMapper>(); using var context = new WebApiContext(_seeder.DbContextOptions); _adminGroup = _mapper.Map <UserGroupGetDto>(context.GetAdminGroup()); _userGroup = _mapper.Map <UserGroupGetDto>(context.GetUserGroup()); _activeState = _mapper.Map <UserStateGetDto>(context.GetActiveState()); _blockedState = _mapper.Map <UserStateGetDto>(context.GetBlockedState()); _seeder.MakeAllActive(); }