public async Task DeleteNotExistingClub() { var stadiumsList = new List <Stadium> { new Stadium { Id = 1, Name = "Old Trafford", Capacity = 76000 } }; var countriesList = new List <Country> { new Country { Id = 1, Name = "England", Code = "EN" } }; var clubsList = new List <Club>(); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); var mockCountryRepo = new Mock <IRepository <Country> >(); var mockClubRepo = new Mock <IRepository <Club> >(); mockClubRepo.Setup(r => r.All()).Returns(clubsList.AsQueryable()); var clubService = new ClubService(mockClubRepo.Object, mockCountryRepo.Object, mockStadiumRepo.Object); await Assert.ThrowsAsync <Exception>(() => clubService.DeleteAsync(1)); }
public async Task SaveAndUpdateClub() { var stadiumsList = new List <Stadium> { new Stadium { Id = 1, Name = "Old Trafford", Capacity = 76000 } }; var countriesList = new List <Country> { new Country { Id = 1, Name = "England", Code = "EN" } }; var clubsList = new List <Club>(); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => stadiumsList.FirstOrDefault(c => c.Id == id)); var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockClubRepo = new Mock <IRepository <Club> >(); mockClubRepo.Setup(r => r.All()).Returns(clubsList.AsQueryable()); mockClubRepo.Setup(r => r.AddAsync(It.IsAny <Club>())).Callback <Club>(club => clubsList.Add(new Club { Id = 1, Name = club.Name, Country = club.Country, HomeStadium = club.HomeStadium })); var clubService = new ClubService(mockClubRepo.Object, mockCountryRepo.Object, mockStadiumRepo.Object); var clubViewModel = new ClubViewModel { Name = "Manchester United", CountryId = 1, HomeStadiumId = 1 }; await clubService.CreateAsync(clubViewModel); var updatedViewModel = new ClubViewModel { Id = 1, Name = "Newcastle United", CountryId = 1, HomeStadiumId = 1 }; await clubService.UpdateAsync(updatedViewModel); var savedClub = clubService.Get(1); Assert.Equal(1, savedClub.Id); Assert.Equal("Newcastle United", savedClub.Name); }
public async Task GetCityProfileAsync_WithUser_ReturnsCityProfile() { // Arrange ClubService clubService = CreateClubService(); _userManager .Setup(u => u.GetUserIdAsync(It.IsAny <DataAccessClub.User>())) .ReturnsAsync(stringId); _userManager .Setup(u => u.GetRolesAsync(It.IsAny <DataAccessClub.User>())) .ReturnsAsync(new List <string>()); var mockList = new Mock <IList <string> >(); mockList .Setup(m => m.Contains(It.IsAny <string>())) .Returns(true); _clubAccessService .Setup(c => c.HasAccessAsync(It.IsAny <DataAccessClub.User>(), It.IsAny <int>())) .ReturnsAsync(true); _repoWrapper .Setup(r => r.ClubMembers.GetFirstOrDefaultAsync(It.IsAny <Expression <Func <ClubMembers, bool> > >(), It.IsAny <Func <IQueryable <ClubMembers>, IIncludableQueryable <ClubMembers, object> > >())) .ReturnsAsync(new ClubMembers()); // Act var result = await clubService.GetClubProfileAsync(Id, It.IsAny <DataAccessClub.User>()); // Assert Assert.NotNull(result); Assert.IsInstanceOf <ClubProfileDTO>(result); }
public GameProcessController() { var contex = new BulkaContext(); _processService = new GameProcessService(contex); _clubService = new ClubService(contex); }
static ServiceLocator() { AddressService = new AddressService(); BoatService = new BoatService(); ClubService = new ClubService(); UserService = new UserService(); EntryService = new EntryService(); RaceEventService = new RaceEventService(); RegattaService = new RegattaService(); SocialEventService = new SocialEventService(); TeamService = new TeamService(); EmailService = new EmailService(); PhoneNumberService = new PhoneNumberService(); RegisteredUserService = new RegisteredUserService(); ResultService = new ResultService(); UserRoleService = new UserRoleService(); ClubsUsersUserRolesJunctionsService = new Clubs_Users_UserRoles_JunctionsService(); RegattasUsersUserRolesJunctionsService = new Regattas_Users_UserRoles_JunctionsService(); RegisteredUserSocialEventService = new RegisteredUser_SocialEventService(); TeamRaceEventService = new Team_RaceEventService(); TeamRegisteredUserService = new Team_RegisteredUserService(); BoatService = new BoatService(); SocialEventsUsersUserRolesJunctionsService = new SocialEvents_Users_UserRoles_JunctionsService(); RaceEventsUsersUserRolesJunctionsService = new RaceEvents_Users_UserRoles_JunctionsService(); ClubsEmailsService = new ClubsEmailsService(); ClubsPhoneNumbersService = new ClubsPhoneNumbersService(); }
public bool Execute(GameServer server, Player plr, string[] args) { Task.Factory.StartNew(() => { var message = "Reloading clubs, server may lag for a short period of time..."; if (plr == null) { Console.WriteLine(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } server.ResourceCache.Clear(ResourceCacheType.Clubs); server.ClubManager = new ClubManager(server.ResourceCache.GetClubs()); ClubService.Update(null, true); message = "Club reload completed"; if (plr == null) { Console.WriteLine(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } }); return(true); }
public void SetUp() { _unitOfWork = new Mock <IUnitOfWork>(); _clubRepository = new Mock <IClubRepository>(); _clubService = new ClubService(_unitOfWork.Object, _clubRepository.Object); }
public ActionResult DeleteConfirmed(int?id) { try { using (var clubService = new ClubService()) { //var addressService = new AddressService(); var foundClubToDelete = clubService.EagerDisconnectedService.FindBy(x => x.Id == id.Value); if (foundClubToDelete == null) { throw new NullReferenceException(); } var selectedClub = foundClubToDelete.First(); //TODO Find Address and "Delete" // clubService.EagerDisconnectedService.Delete(selectedClub); //addressService.EagerDisconnectedService.Delete(new AddressDTO(address)); } return(RedirectToAction("Index")); } catch (Exception e) { TempData["ResultMessage"] = e.Message; return(View("Error")); } }
public EventController(ClubService clubService, EventService eventService, UserService userService) { this.clubService = clubService; this.eventService = eventService; this.userService = userService; }
// GET: Clubs/Details/5 public ActionResult Details(int?id) { if (id == null || id == 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var mapperConfig = new MapperConfiguration(cfg => { cfg.CreateMap <ClubDTO, ClubDetailsViewModel>(); }); try { using (var clubService = new ClubService()) { var clubList = clubService.EagerDisconnectedService.FindBy(x => x.Id == id); if (clubList == null) { return(HttpNotFound()); } var club = new ClubDetailsViewModel(); var mapper = mapperConfig.CreateMapper(); mapper.Map(clubList.First(), club); return(View(club)); } } catch (Exception e) { TempData["ResultMessage"] = e.Message; return(View("Error")); } }
public async Task <bool> Execute(GameServer server, Player plr, string[] args) { await Task.Run(async() => { var message = "Reloading clubs, server may lag for a short period of time..."; if (plr == null) { CommandManager.Logger.Information(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } server.ResourceCache.Clear(ResourceCacheType.Clubs); server.ClubManager = new ClubManager(server.ResourceCache.GetClubs()); await ClubService.Update(null, true); message = "Club reload completed"; if (plr == null) { CommandManager.Logger.Information(message); } else { plr.SendConsoleMessage(S4Color.Green + message); } }); return(true); }
public async Task ClubServiceAircrafFlightTest() { ImportDataTest import = new ImportDataTest(); import.InitContext(); try { _context = import._context; cr = new ClubRepository(_context); AircraftLogBookRepository acr = new AircraftLogBookRepository(_context); FlightRepository fr = new FlightRepository(_context); MemberRepository mr = new MemberRepository(_context); AircraftRepository ar = new AircraftRepository(_context); ClubService clubService = new ClubService(cr, mr, fr, ar, acr, null); int aircraftId = 8; ICollection <Flight> flights = await clubService.GetClubAircraftFlight("BAZ", aircraftId); var group = flights.GroupBy(o => o.Pilot); foreach (var g in group) { System.Diagnostics.Debug.WriteLine(g.FirstOrDefault()?.Pilot?.FirstName); foreach (var gi in g) { System.Diagnostics.Debug.WriteLine(gi.ToString()); } } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } }
public LOGINController() { igroup36_prodEntities db = new igroup36_prodEntities(); cCustomer = new CustomerService(db); cClub = new ClubService(db); }
public ActionResult GetClubs(int?clubid = null) { _logger.LogInformation("Logging Clubs Info"); List <Club> clubs = new ClubService(null, clubid).GetClubs(); return(Ok(clubs)); }
public HomeController(UserManager <User> userManager, ClubService clubService, UserService userService, PostService postService) { this.userManager = userManager; this.userService = userService; this.clubService = clubService; this.postService = postService; }
public ActionResult GetClubDetails(int?siteid = null, int?clubid = null) { _logger.LogInformation("Logging ClubDetails Info"); List <ClubDetails> details = new ClubService(siteid, clubid).GetClubDetails(); return(Ok(details)); }
public async Task GetAllDtoTest() { ClubService ClubService = CreateClubService(); var result = await ClubService.GetAllDtoAsync(null); Assert.NotNull(result); }
public PostController(PostService postService, ClubService clubService, UserManager <User> userManager) { this.postService = postService; this.clubService = clubService; this.userManager = userManager; }
// GET: Club public ActionResult Index() { clubService = new ClubService(); var clubs = clubService.All(); // we geven de lijst met clubs mee aan de view return(View(clubs)); }
public ClubController(IMapper mapper) { _mapper = mapper; clubService = new ClubService(); vakService = new VakService(); stadionService = new StadionService(); stadionVakService = new StadionVakService(); }
// GET: Entries/Create public ActionResult Create() { EntryCreateViewModel entryCreateViewModel = new EntryCreateViewModel(); var boatList = new List <BoatDropDownListViewModel>(); var clubList = new List <ClubDropDownListViewModel>(); var regattaList = new List <RegattaDropDownListViewModel>(); var mapperConfig = new MapperConfiguration(cfg => { cfg.CreateMap <BoatDTO, BoatDropDownListViewModel>(); cfg.CreateMap <ClubDTO, ClubDropDownListViewModel>(); cfg.CreateMap <RegattaDTO, RegattaDropDownListViewModel>(); }); using (var boatService = new BoatService()) using (var clubService = new ClubService()) using (var regattaService = new RegattaService()) { try { var allBoatsDto = boatService.EagerDisconnectedService.GetAll().Where(x => x.Active); if (allBoatsDto == null) { throw new NullReferenceException(); } var mapper = mapperConfig.CreateMapper(); mapper.Map(allBoatsDto, boatList); var allclubsDto = clubService.EagerDisconnectedService.FindByInclude(x => x.Active); if (allclubsDto == null) { throw new NullReferenceException(); } var mapper2 = mapperConfig.CreateMapper(); mapper.Map(allclubsDto, clubList); var allregattasDto = regattaService.EagerDisconnectedService.FindByInclude(x => x.Active); if (allregattasDto == null) { throw new NullReferenceException(); } var mapper3 = mapperConfig.CreateMapper(); mapper.Map(allregattasDto, regattaList); ViewBag.BoatDropDownList = new SelectList(boatList.OrderBy(b => b.FullBoatName), "Id", "FullBoatName"); ViewBag.ClubDropDownList = new SelectList(clubList.OrderBy(c => c.Name), "Id", "Name"); ViewBag.RegattaDropDownList = new SelectList(regattaList.OrderBy(c => c.Name), "Id", "Name"); return(View()); } catch (Exception e) { TempData["ResultMessage"] = e.Message; return(View("Error")); } } }
public async Task GetByIdTest() { ClubService ClubService = CreateClubService(); var result = await ClubService.GetByIdAsync(GetIdForSearch); Assert.NotNull(result); Assert.IsType <ClubDTO>(result); }
public WedstrijdController(IMapper mapper) { _mapper = mapper; wedstrijdService = new WedstrijdService(); vakService = new VakService(); clubService = new ClubService(); stadionService = new StadionService(); stadionVakService = new StadionVakService(); }
public async Task EditGetTest() { ClubService ClubService = CreateClubService(); var result = await ClubService.EditAsync(GetIdForSearch); Assert.NotNull(result); Assert.IsType <ClubProfileDTO>(result); }
private List <Club> GetAllClubs() { using (var context = new ClubContext()) { var service = new ClubService(context); var clubs = service.GetAll(); return(clubs.ToList()); } }
public IHttpActionResult Get(int id, int?unionId = null) { SeasonsRepo seasonsRepo = new SeasonsRepo(); int? seasonId = unionId != null?seasonsRepo.GetLastSeasonByCurrentUnionId(unionId.Value) : (int?)null; var clubInfo = ClubService.GetClub(id, seasonId); return(Ok(clubInfo)); }
public FrmJugador() { InitializeComponent(); dgvJugadores.AutoGenerateColumns = false; JugadorService = new JugadorService(); ClubService = new ClubService(); PosicionService = new PosicionService(); LlenarCombo(cb_club, ClubService.ObtenerTodosClubes(), "Nombre", "IdClub"); LlenarCombo(cb_posicion, PosicionService.ObtenerTodosPosiciones(), "Nombre", "IdPosicion"); }
public FrmAsignarJugador() { InitializeComponent(); JugadorService = new JugadorService(); EquipoService = new EquipoService(); ClubService = new ClubService(); PosicionService = new PosicionService(); Cargar_comboBox(cbo_equipo, EquipoService.obtenerTodos(), "nombre", "idEquipo"); Cargar_comboBox(cb_posicion, PosicionService.ObtenerTodosPosiciones(), "nombre", "idPosicion"); Cargar_comboBox(cb_club, ClubService.ObtenerTodosClubes(), "nombre", "idClub"); }
public async Task GetClubs_ReturnClubForAdministrationDTOs() { // Arrange ClubService clubService = CreateClubService(); // Act var result = await clubService.GetClubs(); // Assert Assert.NotNull(result); Assert.IsInstanceOf <IEnumerable <ClubForAdministrationDTO> >(result); }
public ClubServiceTests() { _context = Utilities.InMemoryContextBuilder.GetContext(); _clubId = _context.Clubs.First().Id; _clubInitials = _context.Clubs.First().Initials; _mapper = MapperBuilder.GetSailScoresMapper(); _service = new SailScores.Core.Services.ClubService( _context, _mapper ); }
public ServiceList(string url, ResponseToken token) { this.eventService = new EventService(url, token); this.categoryService = new CategoryService(url, token); this.clubService = new ClubService(url, token); this.userService = new UserService(url, token); this.ticketService = new TicketService(url, token); this.meetingService = new MeetingService(url, token); this.invoiceService = new InvoiceService(url, token); this.groupService = new GroupService(url, token); this.expenseService = new ExpenseService(url, token); this.emailService = new EmailService(url, token); this.depositService = new DepositService(url, token); this.customFieldService = new CustomFieldService(url, token); this.taskService = new TaskService(url, token); this.contactService = new ContactService(url, token); }