public IHttpActionResult Get() { StadiumService stadiumService = CreateStadiumService(); var stadium = stadiumService.GetStadium(); return(Ok(stadium)); }
/// <summary> /// /// </summary> /// <param name="apiBaseUrl"></param> /// <param name="primarySubscriptionKey"></param> /// <param name="secondarySubscriptionKey"></param> public FantasyDataClient(string primarySubscriptionKey, string secondarySubscriptionKey) { Uri statApiBaseUrl = NFLConfig.StateApiBaseUrl; Uri scoreApiBaseUrl = NFLConfig.ScoreApiBaseUrl; Uri ProjectionApiBaseUrl = NFLConfig.ProjectionApiBaseUrl; DailyFantasyService = new DailyFantasyService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); SeasonService = new SeasonService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); NewsService = new NewsService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); PlayerGameStatService = new PlayerGameStatService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); PlayerSeasonStatService = new PlayerSeasonStatService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); TeamDefenseService = new TeamDefenseService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); GameService = new GameService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); InjuryService = new InjuryService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); StadiumService = new StadiumService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); TeamService = new TeamService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); BoxScoreService = new BoxScoreService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); PlayerService = new PlayerService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); ScheduleService = new ScheduleService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); TimeFrameService = new TimeFrameService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); TeamSeasonService = new TeamSeasonService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); TeamGameService = new TeamGameService(statApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); ScoresService = new ScoresService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); ScoresService = new ScoresService(scoreApiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); DfsSlateService = new DfsSlateService(ProjectionApiBaseUrl.AbsoluteUri, NFLConfig.ProjectionPrimarySubscriptionKey, NFLConfig.ProjectionSecondarySubscriptionKey); PlayerGameProjectionsService = new PlayerGameProjectionService(ProjectionApiBaseUrl.AbsoluteUri, NFLConfig.ProjectionPrimarySubscriptionKey, NFLConfig.ProjectionSecondarySubscriptionKey); PlayerSeasonProjectionService = new PlayerSeasonProjectionService(ProjectionApiBaseUrl.AbsoluteUri, NFLConfig.ProjectionPrimarySubscriptionKey, NFLConfig.ProjectionSecondarySubscriptionKey); }
//Helper method: private StadiumService CreateStadiumService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new StadiumService(userId); return(service); }
public async Task UpdateNotExistingStadium() { var countriesList = new List <Country> { new Country { Id = 1, Name = "Spain", Code = "SP" } }; var stadiumsList = new List <Stadium>(); var mockCountryRepo = new Mock <IRepository <Country> >(); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.All()).Returns(stadiumsList.AsQueryable()); var stadiumService = new StadiumService(mockStadiumRepo.Object, mockCountryRepo.Object); var updatedViewModel = new StadiumViewModel { Id = 1, Name = "Santiago Bernabeu", CountryId = 1 }; await Assert.ThrowsAsync <Exception>(() => stadiumService.UpdateAsync(updatedViewModel)); }
// GET: Stadium public ActionResult Index() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new StadiumService(userId); var model = service.GetStadiums(); return(View(model)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Places,PayForPlace")] Stadium stadium) { if (ModelState.IsValid) { await StadiumService.sharedInstance().UpdateStadiums(stadium); return(RedirectToAction("Index")); } return(View(stadium)); }
// GET: Games/Create public async Task <ActionResult> Create() { var stadiums = await StadiumService.sharedInstance().GetStadiums(); var teams = await TeamService.sharedInstance().getTeams(); ViewBag.StadiumId = new SelectList(stadiums, "Id", "Id"); ViewBag.FirstTeamId = new SelectList(teams, "Id", "TeamName"); ViewBag.SecondTeamId = new SelectList(teams, "Id", "TeamName"); return(View()); }
public IHttpActionResult Get(int?id) { if (id == null) { return(BadRequest()); } StadiumService service = CreateStadiumService(); return(Ok(service.GetStadiumByID(id.Value))); }
public async Task SaveAndUpdateStadiumWithNameOfAnotherdExistingStadium() { var countriesList = new List <Country> { new Country { Id = 1, Name = "Spain", Code = "SP" } }; var stadiumsList = new List <Stadium>(); var id = 1; var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.All()).Returns(stadiumsList.AsQueryable()); mockStadiumRepo.Setup(r => r.AddAsync(It.IsAny <Stadium>())).Callback <Stadium>(stadium => stadiumsList.Add(new Stadium { Id = id++, Name = stadium.Name, Capacity = stadium.Capacity, Country = stadium.Country })); var stadiumService = new StadiumService(mockStadiumRepo.Object, mockCountryRepo.Object); var firstStadiumViewModel = new StadiumViewModel { Name = "Santiago Bernabeu", CountryId = 1 }; var secondStadiumViewModel = new StadiumViewModel { Name = "Camp Nou", CountryId = 1 }; await stadiumService.CreateAsync(firstStadiumViewModel); await stadiumService.CreateAsync(secondStadiumViewModel); var secondUpdatedViewModel = new StadiumViewModel { Id = 2, Name = "Santiago Bernabeu", CountryId = 1 }; await Assert.ThrowsAsync <Exception>(() => stadiumService.UpdateAsync(secondUpdatedViewModel)); }
public async Task <ActionResult> Create([Bind(Include = "Id,StadiumId,FirstTeamId,SecondTeamId,Result,Audience,GameDate")] Game game) { if (ModelState.IsValid) { await GameService.sharedInstance().addGame(game); return(RedirectToAction("Index")); } var stadiums = await StadiumService.sharedInstance().GetStadiums(); ViewBag.StadiumId = new SelectList(stadiums, "Id", "Id", game.StadiumId); return(View(game)); }
public async Task GetAllStadiumsAsKeyValuePairs() { var countriesList = new List <Country> { new Country { Id = 1, Name = "Spain", Code = "SP" } }; var stadiumsList = new List <Stadium>(); var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.All()).Returns(countriesList.AsQueryable()); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.All()).Returns(stadiumsList.AsQueryable()); mockStadiumRepo.Setup(r => r.AddAsync(It.IsAny <Stadium>())).Callback <Stadium>(stadium => stadiumsList.Add(new Stadium { Id = 1, Name = stadium.Name, Capacity = stadium.Capacity, Country = stadium.Country })); var stadiumService = new StadiumService(mockStadiumRepo.Object, mockCountryRepo.Object); var firstStadiumViewModel = new StadiumViewModel { Name = "Santiago Bernabeu", CountryId = 1, CountriesItems = new CountryService(mockCountryRepo.Object).GetAllAsKeyValuePairs() }; var secondStadiumViewModel = new StadiumViewModel { Name = "Camp Nou", CountryId = 1, CountriesItems = new CountryService(mockCountryRepo.Object).GetAllAsKeyValuePairs() }; await stadiumService.CreateAsync(firstStadiumViewModel); await stadiumService.CreateAsync(secondStadiumViewModel); var keyValuePairs = stadiumService.GetAllAsKeyValuePairs().ToList(); Assert.True(keyValuePairs.Count == 2); Assert.True(firstStadiumViewModel.CountriesItems.Count() == 1); Assert.True(secondStadiumViewModel.CountriesItems.Count() == 1); }
// GET: Stadium/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Stadium stadium = await StadiumService.sharedInstance().GetStadium((int)id); if (stadium == null) { return(HttpNotFound()); } return(View(stadium)); }
public async Task SaveAndUpdateStadium() { var countriesList = new List <Country> { new Country { Id = 1, Name = "Spain", Code = "SP" } }; var stadiumsList = new List <Stadium>(); var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.All()).Returns(stadiumsList.AsQueryable()); mockStadiumRepo.Setup(r => r.AddAsync(It.IsAny <Stadium>())).Callback <Stadium>(stadium => stadiumsList.Add(new Stadium { Id = 1, Name = stadium.Name, Capacity = stadium.Capacity, Country = stadium.Country })); var stadiumService = new StadiumService(mockStadiumRepo.Object, mockCountryRepo.Object); var stadiumViewModel = new StadiumViewModel { Name = "Santiago Bernabeu", CountryId = 1 }; await stadiumService.CreateAsync(stadiumViewModel); var updatedViewModel = new StadiumViewModel { Id = 1, Name = "Santiago Bernabeu", CountryId = 1 }; await stadiumService.UpdateAsync(updatedViewModel); var savedStadium = stadiumService.Get(1); Assert.Equal(1, savedStadium.Id); Assert.Equal("Santiago Bernabeu", savedStadium.Name); }
public IHttpActionResult Delete(int?id) { if (id == null) { return(BadRequest()); } StadiumService service = CreateStadiumService(); if (service.DeleteStadium(id.Value)) { return(Ok()); } return(InternalServerError()); }
/// <summary> /// /// </summary> /// <param name="apiBaseUrl"></param> /// <param name="primarySubscriptionKey"></param> /// <param name="secondarySubscriptionKey"></param> public FantasyDataClient(Uri apiBaseUrl, string primarySubscriptionKey, string secondarySubscriptionKey) { DailyFantasyService = new DailyFantasyService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); SeasonService = new SeasonService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); NewsService = new NewsService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); PlayerGameStatService = new PlayerGameStatService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); PlayerSeasonStatService = new PlayerSeasonStatService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); TeamDefenseService = new TeamDefenseService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); GameService = new GameService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); InjuryService = new InjuryService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); StadiumService = new StadiumService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); TeamService = new TeamService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); BoxScoreService = new BoxScoreService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); PlayerService = new PlayerService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); ScheduleService = new ScheduleService(apiBaseUrl.AbsoluteUri, primarySubscriptionKey, secondarySubscriptionKey); }
public IHttpActionResult Put(StadiumEdit model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } StadiumService service = CreateStadiumService(); if (service.UpdateExistingStadium(model)) { return(Ok()); } return(InternalServerError()); }
static void Main(string[] args) { logger.Debug("Bot started"); matchRequestService = new MatchRequestService(ClientConfigurator.CreateWebClient(ConfigurationManager.AppSettings["authToken"])); userFavouriteService = new UserFavouriteService(); stadiumService = new StadiumService(); webClient = ClientConfigurator.CreateWebClient(ConfigurationManager.AppSettings["authToken"]); markupCreator = new MarkupCreator(); botClient = new TelegramBotClient(ConfigurationManager.AppSettings["botToken"]); //event handlers botClient.OnMessage += Bot_OnMessage; botClient.OnCallbackQuery += BotClient_OnCallbackQuery; botClient.StartReceiving(); Thread.Sleep(int.MaxValue); }
// GET: Games/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Game game = await GameService.sharedInstance().getGame((int)id); if (game == null) { return(HttpNotFound()); } var stadiums = await StadiumService.sharedInstance().GetStadiums(); var teams = await TeamService.sharedInstance().getTeams(); ViewBag.StadiumId = new SelectList(stadiums, "Id", "Id"); ViewBag.FirstTeamId = new SelectList(teams, "Id", "TeamName"); ViewBag.SecondTeamId = new SelectList(teams, "Id", "TeamName"); return(View(game)); }
public async Task SaveAndLoadStadium() { var countriesList = new List <Country> { new Country { Id = 1, Name = "Spain", Code = "SP" } }; var stadiumsList = new List <Stadium>(); var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.All()).Returns(stadiumsList.AsQueryable()); mockStadiumRepo.Setup(r => r.AddAsync(It.IsAny <Stadium>())).Callback <Stadium>(stadium => stadiumsList.Add(stadium)); mockStadiumRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => stadiumsList.FirstOrDefault(c => c.Id == id)); var stadiumService = new StadiumService(mockStadiumRepo.Object, mockCountryRepo.Object); var stadiumViewModel = new StadiumViewModel { Name = "Santiago Bernabeu", Capacity = 80000, FoundedOn = DateTime.Now, CountryId = 1, CountryName = "Spain" }; await stadiumService.CreateAsync(stadiumViewModel); var savedStadium = stadiumService.Get(10, false); var lastSavedStadium = stadiumService.GetAll().LastOrDefault(); Assert.Null(savedStadium); Assert.Equal("Santiago Bernabeu", lastSavedStadium.Name); Assert.Equal("Spain", stadiumViewModel.CountryName); Assert.Equal(80000, lastSavedStadium.Capacity); }
public async Task SaveAndLoadStadiumsWithRelatedData() { var countriesList = new List <Country> { new Country { Id = 1, Name = "Spain", Code = "SP" } }; var stadiumsList = new List <Stadium>(); var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.All()).Returns(stadiumsList.AsQueryable()); mockStadiumRepo.Setup(r => r.AddAsync(It.IsAny <Stadium>())).Callback <Stadium>(stadium => stadiumsList.Add(new Stadium { Id = 1, Name = stadium.Name, Capacity = stadium.Capacity, Country = stadium.Country })); var stadiumService = new StadiumService(mockStadiumRepo.Object, mockCountryRepo.Object); var stadiumViewModel = new StadiumViewModel { Name = "Santiago Bernabeu", Capacity = 80000, FoundedOn = DateTime.Now, CountryId = 1 }; await stadiumService.CreateAsync(stadiumViewModel); var savedStadiums = stadiumService.GetAll(); Assert.True(savedStadiums.Count() == 1); }
public async Task SaveTwoStadiumsWithSameNames() { var countriesList = new List <Country> { new Country { Id = 1, Name = "Spain", Code = "SP" } }; var stadiumsList = new List <Stadium>(); var mockCountryRepo = new Mock <IRepository <Country> >(); mockCountryRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => countriesList.FirstOrDefault(c => c.Id == id)); var mockStadiumRepo = new Mock <IRepository <Stadium> >(); mockStadiumRepo.Setup(r => r.All()).Returns(stadiumsList.AsQueryable()); mockStadiumRepo.Setup(r => r.AddAsync(It.IsAny <Stadium>())).Callback <Stadium>(stadium => stadiumsList.Add(stadium)); var stadiumService = new StadiumService(mockStadiumRepo.Object, mockCountryRepo.Object); var firstStadiumViewModel = new StadiumViewModel { Name = "Santiago Bernabeu", CountryId = 1 }; var secondStadiumViewModel = new StadiumViewModel { Name = "Santiago Bernabeu", CountryId = 1 }; await stadiumService.CreateAsync(firstStadiumViewModel); await Assert.ThrowsAsync <Exception>(() => stadiumService.CreateAsync(secondStadiumViewModel)); }
private void InitializeCommands() { AddStadiumCommand = new RelayCommand(AddStadium); RemoveStadiumCommand = new RelayCommand(RemoveStadium); EditStadiumCommand = new RelayCommand(EditStadium); AddClubCommand = new RelayCommand(AddClub); RemoveClubCommand = new RelayCommand(RemoveClub); EditClubCommand = new RelayCommand(EditClub); AddTicketCommand = new RelayCommand(AddTicket); RemoveTicketCommand = new RelayCommand(RemoveTicket); EditTicketCommand = new RelayCommand(EditTicket); AddMatchCommand = new RelayCommand(AddMatch); RemoveMatchCommand = new RelayCommand(RemoveMatch); EditMatchCommand = new RelayCommand(EditMatch); AddReffereCommand = new RelayCommand(AddReffere); RemoveReffereCommand = new RelayCommand(RemoveReffere); EditReffereCommand = new RelayCommand(EditReferee); AddPlayerCommand = new RelayCommand(AddPlayer); RemovePlayerCommand = new RelayCommand(RemovePlayer); EditPlayerCommand = new RelayCommand(EditPlayer); AddRecordCommand = new RelayCommand(AddRecord); RemoveRecordCommand = new RelayCommand(RemoveRecord); EditRecordCommand = new RelayCommand(EditRecord); AddTimetableCommand = new RelayCommand(AddTimetable); RemoveTimetableCommand = new RelayCommand(RemoveTimetable); EditTimetableCommand = new RelayCommand(EditTimetable); AddStaffCommand = new RelayCommand(AddStaff); RemoveStaffCommand = new RelayCommand(RemoveStaff); EditStaffCommand = new RelayCommand(EditStaff); AddWinnersCommand = new RelayCommand(AddWinners); RemoveWinnersCommand = new RelayCommand(RemoveWinners); EditWinnersCommand = new RelayCommand(EditWinners); stadium = new ObservableCollection <StadiumViewModel>(); club = new ObservableCollection <ClubViewModel>(); match = new ObservableCollection <MatchViewModel>(); ticket = new ObservableCollection <TicketViewModel>(); reffere = new ObservableCollection <ReffereViewModel>(); player = new ObservableCollection <PlayerViewModel>(); record = new ObservableCollection <RecordViewModel>(); timetable = new ObservableCollection <TimetableViewModel>(); trainingStaff = new ObservableCollection <TrainingStaffViewModel>(); winners = new ObservableCollection <WinnersViewModel>(); stadiumService = new StadiumService(); clubService = new ClubService(); ticketService = new TicketService(); matchService = new MatchService(); reffereService = new ReffereService(); playerService = new PlayerService(); recordService = new RecordService(); timetableService = new TimetableService(); trainingStaffService = new TrainingStaffService(); winnersService = new WinnersService(); }
// GET: Stadium public async Task <ActionResult> Index() { var stadiums = await StadiumService.sharedInstance().GetStadiums(); return(View(stadiums)); }
public async Task <ActionResult> DeleteConfirmed(int id) { await StadiumService.sharedInstance().DeleteStadium(id); return(RedirectToAction("Index")); }
public IHttpActionResult Get() { StadiumService service = CreateStadiumService(); return(Ok(service.GetAllStadiums())); }