public void SaveOrUpdateChampionat(Championat championat) { var existingChamp = database.Table <Championat>().Where(x => x.Name == championat.Name).FirstOrDefault(); if (existingChamp == null) { database.Insert(championat); existingChamp = database.Table <Championat>().Where(x => x.Name == championat.Name).FirstOrDefault(); championat.Matches.ForEach(m => { m.ChampionatId = existingChamp.Id; SaveOrUpdateMatch(m, championat.Matches); }); } else { championat.Id = existingChamp.Id; existingChamp.Tour = championat.Tour; database.Update(existingChamp); championat.Matches.ForEach(m => { m.ChampionatId = championat.Id; SaveOrUpdateMatch(m, championat.Matches); }); } }
private void ShowMatches(Championat champ) { var matches = App.Sql.GetCollection <Match>().Where(m => m.ChampionatId == champ.Id).ToList(); Navigation.PushAsync(new LeaguePage(matches) { Title = champ.Name }); }
private void ShowMatches(Championat champ) { var matches = DataBase.Sql.Table <Match>().Where(m => m.ChampionatId == champ.Id).ToList(); Navigation.PushAsync(new LeaguePage(matches) { Title = champ.Name }); }
private static Match CreateMatch(IDocument document, Championat championat) { var match = new Match(); GetCommand(document, match); GetInfo(document, match, championat); ShapingUrlForHttpRequest(document, match); return(match); }
private static Championat CreateChampionat(IDocument document) { var championat = new Championat(); championat.SportId = 1; championat.Name = document.QuerySelectorAll("section").Where(x => x.ClassName == "general-info").First().QuerySelectorAll("div").Where(x => x.ClassName == "title-holder").First(). QuerySelectorAll("h1").Where(x => x.ClassName == "name").First().TextContent; championat.Matches = new List <Match>(); return(championat); }
private static void GetInfo(IDocument document, Match match, Championat championat) { var info = document.QuerySelectorAll("div").Where(x => x.ClassName == "info").First(); match.Status = info.QuerySelectorAll("div").Where(x => x.ClassName == "broadcasting").First().QuerySelector("span").TextContent; match.Date = info.QuerySelectorAll("div").Where(x => x.ClassName == "date set-offset-datetime").First().TextContent; match.Stadium = info.QuerySelectorAll("div").Where(x => x.ClassName == "definition").First(). QuerySelectorAll("span").Where(x => x.ClassName == "dd text").First().TextContent; championat.Tour = document.QuerySelectorAll("span").Where(x => x.ClassName == "tour").First().TextContent; }