public async Task getAnnouncementsTest() { IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddJsonFile("AppSettings.json"); IConfiguration configuration = configurationBuilder.Build(); GymRepository gym = new GymRepository(DbContext); await gym.addGym(new Gym { GymName = "testName", GymBranch = "testBranch" }); NotificationsRepository notif = new NotificationsRepository(DbContext); await notif.addNotification(new Notifications { Body = "body", Date = DateTime.Now, Heading = "heading", GymIdForeignKey = 1 }); var controller = new NotificationsController(new NotificationSettingsRepository(DbContext), notif, gym, new Mailer(configuration)); var okObjectResult = Assert.IsType <Task <ActionResult <Notifications[]> > >(controller.getAllAnnouncements(1)); //Assert.IsNotType<string>(okObjectResult.Value); }
private async Task <List <IGym> > GetGymsByNameAsync(string name, FenceConfiguration[] fences = null) { Dictionary <string, int> aliasCache = new Dictionary <string, int>(); aliasCache.Add("spital", 37); aliasCache.Add("reha", 36); if (aliasCache.ContainsKey(name.ToLower())) { var gymId = aliasCache[name.ToLower()]; return(await Task.FromResult(GymRepository.FindAll(e => e.Id == gymId).ToList())); } else { if (fences != null && fences.Any()) { var fortIds = new List <int>(); foreach (var fence in fences) { var ids = GymsByFences.GetOrAdd(fence, GetFortIdsForFence); fortIds.AddRange(ids); } fortIds = fortIds.Distinct().ToList(); return(await GymRepository.FindAll(e => fortIds.Contains(e.Id) && e.Name.Contains(name)).ToListAsync()); } else { return(await GymRepository.FindAll(e => e.Name.Contains(name)).ToListAsync()); } } }
public static OcrService GetOcrService(IConfigurationService configurationService, Hydro74000Context context) { IGymRepository gymRepository = new GymRepository(context); IRaidRepository raidRepository = new RaidRepository(context); var localizationService = new LocalizationService(); var gymService = new GymService(gymRepository, localizationService, configurationService); var raidbossService = new RaidbossService(); var fileWatcherService = new FileWatcherService(); var pokemonService = new PokemonService(raidbossService, localizationService, fileWatcherService); var raidService = new RaidService(raidRepository, gymService, pokemonService, raidbossService, localizationService); return(new OcrService(configurationService, gymService, pokemonService, raidService, localizationService)); }
public async Task ChangePassword() { IConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); configurationBuilder.AddJsonFile("AppSettings.json"); IConfiguration configuration = configurationBuilder.Build(); GymRepository gym = new GymRepository(DbContext); await gym.addGym(new Gym { GymName = "testName", GymBranch = "testBranch" }); GymMemberRepository gymMember = new GymMemberRepository(DbContext); bool add = await gymMember.addMember(new GymMember { MembershipId = "1", Email = "*****@*****.**", GymId = 1, Name = "name", Surname = "surname", PhoneNumber = "0321456956", UserType = Data.Enums.UserTypes.Instructor }); Assert.True(add); var userController = new UserController(new UserRepository(DbContext), gymMember, gym, new NotificationSettingsRepository(DbContext), new PasswordResetRepository(DbContext), new Mailer(configuration), new GymApplicationRepository(DbContext), new ApplicationCodeRepository(DbContext)); ActionResult <UserResponseModel> signedup = await userController.signUp(new SignUpRequestModel { username = "******", password = "******", gymBranch = "testBranch", gymMemberId = "1", gymName = "testName" }); ActionResult <UserResponseModel> changedPassword = await userController.changePassword(new ChangePasswordRequestModel { username = "******", oldPassword = "******", newPassword = "******", }); var okObjectResult = Assert.IsType <ActionResult <UserResponseModel> >(changedPassword); Assert.IsNotType <string>(okObjectResult.Value); }
private int[] GetFortIdsForFence(FenceConfiguration fence) { var result = new List <int>(); var allGyms = GymRepository.GetAll().ToList(); foreach (var gym in allGyms) { var coordinate = new Coordinate(gym.Latitude, gym.Longitude); if (fence.Area.Contains(coordinate)) { result.Add(gym.Id); } } return(result.ToArray()); }
private IQueryable <IGym> GetGyms(FenceConfiguration[] fences = null) { if (fences != null && fences.Any()) { var fortIds = new List <int>(); foreach (var fence in fences) { var ids = GymsByFences.GetOrAdd(fence, GetFortIdsForFence); fortIds.AddRange(ids); } fortIds = fortIds.Distinct().ToList(); return(GymRepository.FindAll(e => fortIds.Contains(e.Id))); } return(GymRepository.GetAll()); }
public UnitOfWork(DataBaseFcContext context) { m_context = context; //иницилизация репозиториев Accounts = new AccountRepository(m_context); Employess = new EmployeeRepository(m_context); EmployeRoles = new EmployeeRoleRepository(m_context); EmployeesWorkingStatus = new EmployeeWorkingStatusRepository(m_context); TrainingList = new TrainingListRepository(m_context); Services = new ServiceRepository(m_context); AccountStatus = new AccountStatusRepository(m_context); ServicesInSubscription = new SiSRepository(m_context); Abonements = new AbonementRepository(m_context); UpcomingTrainings = new UpcomingTrainingRepository(m_context); PriceTrainingLists = new PriceTrainingListRepository(m_context); Gyms = new GymRepository(m_context); }
public async Task <IGym> GetGymByIdAsync(int id) { return(await GymRepository.GetAsync(id)); }
public GymController() { _gymRepository = new GymRepository(); }
public UserGymsController(GymRepository gymRepository, IMapper mapper) { this.gymRepository = gymRepository; this.mapper = mapper; }