Exemplo n.º 1
0
        public StartersDetail()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            StartersModel = new StartersViewModel();
        }
Exemplo n.º 2
0
        public StartersViewModel Submit(
            DateTime queryDate)
        {
            var result = new StartersViewModel
            {
                GameDate = queryDate
            };
            var strDate = Utility.UniversalDate(queryDate);

            var httpWebRequest = CreateRequest(
                sport: "baseball",
                league: "mlb",
                apiRequest: "starting_pitchers",
                queryParms: $"season_id=mlb-{queryDate.Year}&on={strDate}");

            var httpResponse
                = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(
                       httpResponse.GetResponseStream()))
            {
                var json = streamReader.ReadToEnd();
                var dto  = JsonConvert.DeserializeObject <StarterDto>(
                    json);

                Players = dto.Players;
                Teams   = dto.Teams;
                Games   = dto.Games;
                result  = MapDtoToViewModel(
                    dto.Pitchers,
                    result);
            }
            return(result);
        }
		public StartersViewModel HotList(
			int weekNo)
		{
			var hotties = new StartersViewModel();

			var weekStarts = Utility.WeekStart(weekNo);
			hotties.StartDate = weekStarts;

			for (int d = 0; d < 7; d++)
			{
				var queryDate = weekStarts.AddDays(d);
				if (queryDate.Equals(DateTime.Now.Date.AddDays(-1)))
					break;
				hotties.EndDate = queryDate;
				var result = _startersRepository.Submit(queryDate);
				foreach (var sp in result.Pitchers)
				{
					var logResult = _gameLogRepository.Submit(
						queryDate,
						sp.Slug);
					if (logResult.IsSuccess)
					{
						var gl = logResult.Value;
						result.Add(gl, sp.Slug);
						if (IsHottie(sp, gl))
							hotties.Add(sp, gl);
					}
				}
			}
			return hotties;
		}
Exemplo n.º 4
0
        public StartersDetail()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            StartersModel = new StartersViewModel();
        }
Exemplo n.º 5
0
        public StartersPage()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            StartersModel = new StartersViewModel();
            DataContext   = this;
        }
Exemplo n.º 6
0
        public StartersPage()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            StartersModel = new StartersViewModel();
            DataContext = this;
        }
Exemplo n.º 7
0
        public StartersList()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            StartersModel = new StartersViewModel();

            SizeChanged += OnSizeChanged;
        }
Exemplo n.º 8
0
        public StartersList()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            StartersModel = new StartersViewModel();

            SizeChanged += OnSizeChanged;
        }
Exemplo n.º 9
0
        public StartersPage()
        {
            this.InitializeComponent();
            _navigationHelper = new NavigationHelper(this);

            StartersModel = new StartersViewModel();
            DataContext   = this;

            ApplicationView.GetForCurrentView().
            SetDesiredBoundsMode(ApplicationViewBoundsMode.UseVisible);
        }
Exemplo n.º 10
0
 private StartersViewModel MapDtoToViewModel(
     List <PitcherDto> dto,
     StartersViewModel result)
 {
     foreach (var p in dto)
     {
         var pitcher = new Pitcher
         {
             Name        = GetName(p.PlayerId, Players),
             Slug        = GetSlug(p.PlayerId, Players),
             Throws      = GetHandedness(p.PlayerId, Players),
             Wins        = int.Parse(p.Wins),
             Losses      = int.Parse(p.Losses),
             Era         = decimal.Parse(p.Era),
             TeamId      = TeamSlugFor(p.TeamId, Teams),                 // did not want to clear the cache
             TeamSlug    = TeamSlugFor(p.TeamId, Teams),
             TeamName    = TeamNameFor(p.TeamId, Teams),
             FantasyTeam = SetFantasyTeam(p),
         };
         result.Pitchers.Add(pitcher);
     }
     return(result);
 }