Esempio n. 1
0
        /**
         * Routes user to page that shows a list of all current, open games
         */
        public ActionResult GameList()
        {
            ViewBag.Venue = new SelectList(_venueService.GetAllVenues(), "VenueId", "Name");
            ViewBag.Sport = new SelectList(_gameService.GetAllSports(), "SportId", "SportName");

            // Get games that are open and that have not already passed and order by games happening soonest
            List <Game> games = _gameService.GetAllCurrentOpenGames();

            List <GameListViewModel> model = new List <GameListViewModel>();

            foreach (var game in games)
            {
                var gameToAdd = new GameListViewModel();
                gameToAdd.GameId    = game.GameId;
                gameToAdd.Sport     = _gameService.GetSportNameById(game.SportId);
                gameToAdd.Venue     = _venueService.GetVenueNameById(game.VenueId);
                gameToAdd.StartDate = game.StartTime;
                gameToAdd.EndDate   = game.EndTime;

                if (game.ContactId != null)
                {
                    gameToAdd.ContactId   = game.ContactId;
                    gameToAdd.ContactName = _contactService.GetContactById(game.ContactId).Username;
                }

                model.Add(gameToAdd);
            }

            return(View(model));
        }
Esempio n. 2
0
        /*
         * Show a list of venues
         */
        public ActionResult Index()
        {
            _venueService.UpdateVenues();

            // Create view model for list of venues
            SearchVenueViewModel model = new SearchVenueViewModel();

            model.Venues = new List <VenueViewModel>();
            List <Venue> venues = _venueService.GetAllVenues();

            foreach (var venue in venues)
            {
                // get location of venue
                Location location = _venueService.GetVenueLocation(venue.VenueId);

                // get the rating
                List <Review> reviews = _venueService.GetVenueReviews(venue.VenueId);

                decimal?avgRating;
                if (reviews.Count > 0)
                {
                    avgRating = (decimal)reviews.Average(r => r.Rating);
                }
                else
                {
                    avgRating = null;
                }


                model.Venues.Add(new VenueViewModel
                {
                    Address1       = venue.Address1,
                    Address2       = venue.Address2,
                    City           = venue.City,
                    Name           = venue.Name,
                    Phone          = venue.Phone,
                    State          = venue.State,
                    VenueId        = venue.VenueId,
                    ZipCode        = venue.ZipCode,
                    AverageRating  = avgRating,
                    LatitudeCoord  = location.Latitude,
                    LongitudeCoord = location.Longitude,
                });
            }

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult GetPredictionFromWebService()
        {
            // var venueName = Request.Form["venueName"];

            //If the request is empty return error
            if (Request.Form["SportName"] == "")
            {
                ViewData.ModelState.AddModelError("NoSport", "you have not selected any sport!");
                return(RedirectToAction("Index"));
            }
            int sportId = Parse(Request.Form["SportName"]);


            var sportName = _gameService.GetSportNameById(sportId);

            //Pass the sport name to the Machine Learning Class
            if (!string.IsNullOrEmpty(sportName))
            {
                var resultResponse = _trendingWebServices.InvokeRequestResponseService <ResultOutcome>(sportName).Result;
                if (resultResponse != null)
                {
                    var result = resultResponse.Results.Output1.Value.Values;
                    TrendingResult = new TrendingModel()
                    {
                        VenueName = result[0, 17],
                        SportName = result[0, 1]
                    };
                }
            }

            // store the returned Venue Name
            string venName = TrendingResult.VenueName;

            // Find the venue by Name and return the ID
            var findVenue = _venueService.GetAllVenues().Where(v => v.Name == venName);
            int venID     = findVenue.ElementAt(0).VenueId;

            //pass Venue Name and ID to View model
            ViewBag.myData = venName;
            ViewBag.venID  = venID;
            PopulateDropdownValues();
            return(View("Index"));
        }
Esempio n. 4
0
 /*
  * Helper method that creates the dropdown of the venues
  */
 public void PopulateDropdownValues()
 {
     ViewBag.Venues = _venueService.GetAllVenues().ToDictionary(v => v.VenueId, v => v.Name);
 }