Esempio n. 1
0
        private async void downloadDone(Task<List<Models.Calendrier>> result)
        {
            await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                List<Models.Calendrier> matchs = result.Result;
                using (BddContext bddContext = new BddContext())
                {
                    foreach (Models.Calendrier match in matchs)
                    {
                        if (bddContext.Calendriers.Any(item => match.Equipe1 == item.Equipe1
                                                                && match.Equipe2 == item.Equipe2
                                                                && match.Categorie == item.Categorie))
                        {
                            Models.Calendrier matchBdd = bddContext.Calendriers.First(item => match.Equipe1 == item.Equipe1
                                                                && match.Equipe2 == item.Equipe2
                                                                && match.Categorie == item.Categorie);
                            matchBdd.Date = match.Date;
                            matchBdd.Score1 = match.Score1;
                            matchBdd.Score2 = match.Score2;
                            bddContext.Entry(matchBdd).State = Microsoft.Data.Entity.EntityState.Modified;
                        }
                        else
                        {
                            bddContext.Calendriers.Add(match);
                        }
                        matchsObservable.Add(match);
                    }
                    bddContext.SaveChanges();
                }
            });

        }
Esempio n. 2
0
 public static async Task<List<Actu>> updateActus()
 {
     List<Actu> actus = await DataDownloader.download<Actu>(ServerConstants.ACTUS_URL, null);
     using (var bddContext = new BddContext())
     {
         foreach (Actu actu in actus)
         {
             if (bddContext.Actus.Any(item => actu.PostId == item.PostId))
             {
                 Actu actuBdd = bddContext.Actus.First(item => actu.PostId == item.PostId);
                 actuBdd.Texte = actu.Texte;
                 actuBdd.Titre = actu.Titre;
                 actuBdd.URL = actu.URL;
                 actuBdd.ImageURL = actu.ImageURL;
                 bddContext.Entry(actuBdd).State = Microsoft.Data.Entity.EntityState.Modified;
             }
             else
             {
                 bddContext.Actus.Add(actu);
             }
         }
         bddContext.SaveChanges();
     }
     Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
     
     localSettings.Values[typeof(Actu).Name + "SyncDate"] = DateTime.Now.ToString();
     return actus;
 }
Esempio n. 3
0
        /// <summary>
        /// Initialise l'objet d'application de singleton.  Il s'agit de la première ligne du code créé
        /// à être exécutée. Elle correspond donc à l'équivalent logique de main() ou WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;

            using(var bdd = new BddContext())
            {
                bdd.Database.Migrate();
            }
        }