private void Initializate() { var matchesJson = File.ReadAllText("Matches.json"); var matches = JsonConvert.DeserializeObject <List <Match> >(matchesJson, new StringEnumConverter()); //var s = JsonConvert.SerializeObject(matches, Formatting.Indented, new StringEnumConverter()); //var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); //var p = Path.Combine(appData, "ScoreKeeper"); //Directory.CreateDirectory(p); //var f = Path.Combine(p, "matches.json"); //File.WriteAllText(f, s); matchesView = new MatchesView(); var matchViewModels = new ObservableCollection <MatchViewModel>(matches.Select(m => new MatchViewModel(m))); matchesView.DataContext = new MatchesViewModel(matchViewModels, new RelayCommand(_ => EditMatch(null)), new RelayCommand(m => EditMatch(((MatchViewModel)m).Match), o => o != null)); statsView = new StatsView(); var statsViewModel = new StatsViewModel(matchViewModels); statsView.DataContext = statsViewModel; navigateToView(matchesView); }
private async void UpdateView() { #if DEBUG MatchesView.ItemsSource = await LoadDataFromService(MatchsDatePicker.Date); #else if (!CrossConnectivity.Current.IsConnected) { DisplayErrorAlert(); } else { MatchesView.ItemsSource = await LoadDataFromService(MatchsDatePicker.Date); } #endif MatchesView.EndRefresh(); }
// GET: Matches/Details/5 public ActionResult Details(int?id, String nameStringW, String valueStringW, String nameStringL, String valueStringL) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Match match = db.Matches.Find(id); if (match == null) { return(HttpNotFound()); } MatchesView mv = db.MatchesViews.Find(id); if (nameStringW != null && valueStringW != null) { db.AddStatistic(id, mv.Winner, nameStringW, valueStringW); try { db.SaveChanges(); } catch (DbUpdateException e) { ViewBag.error = "could not add statistic"; } } if (nameStringL != null && valueStringL != null) { db.AddStatistic(id, mv.Loser, nameStringL, valueStringL); try { db.SaveChanges(); } catch (DbUpdateException e) { ViewBag.error = "could not add statistic"; } } ViewBag.time = match.TimePlayed.ToString(); ViewBag.winnerN = mv.Winner; ViewBag.loserN = mv.Loser; IQueryable <getStatsPair_Result> info = db.getStatsPair(id); return(View(info)); }
private void MatchsDatePicker_DateSelected(object sender, DateChangedEventArgs e) { MatchesView.BeginRefresh(); }