예제 #1
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);
        }
예제 #2
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();
         }
     });
 }
예제 #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();
            }
        }
예제 #4
0
        public void TestFindAllLivre()
        {
            // Arrange
            string username = "******";
            string password = "******";
            string email    = "*****@*****.**";
            string role     = "user";

            //act
            User         u    = new User(username, password, email, role);
            BddContext   bdd  = new BddContext();
            List <Livre> list = bdd.LivreDao.FindAllLivre();
            Dal          dal  = new Dal();

            //assert
            Assert.AreEqual(list, dal.FindAllLivre());
        }
예제 #5
0
        public ActionResult Ajouter(Livre livre)
        {
            using (IDAL dal = new DAL())
            {
                BddContext bdd = new BddContext();
                if (!ModelState.IsValid)

                {
                    var v = dal.CreerUnLivre(livre.TitreLivre, livre.DateParition, livre.UnAuteur.IdAuteur);
                    ViewBag.Message = "Ajout effectué ";

                    return(View(livre));
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
        }
예제 #6
0
        public static void Initialize(BddContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Personnes.Any())
            {
                return;       // DB has been seeded
            }
            DateTime date      = DateTime.Now;
            var      personnes = new Personne[]
            {
                new Personne {
                    Id = 1, Prenom = "Pierre", nom = "Marc", date_naissance = date, note = "a faire", departement = "etude", telephone = "02457262"
                },
            };

            foreach (Personne s in personnes)
            {
                context.Personnes.Add(s);
            }
            context.SaveChanges();
        }
예제 #7
0
        public async Task <IQueryable <T> > GetList(Func <Task <List <T> > > download)
        {
            bool needToUpdate = false;

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            var values = localSettings.Values[typeof(T).Name + "SyncDate"];

            if (values != null)
            {
                DateTime dateSync = DateTime.Parse((string)values);
                if (dateSync < DateTime.Now.AddDays(-7))
                {
                    needToUpdate = true;
                }
            }
            else
            {
                needToUpdate = true;
            }
            IQueryable <T> query;

            if (!needToUpdate)
            {
                // Get from database
                using (var bddContext = new BddContext())
                {
                    query = bddContext.Set <T>().ToList().AsQueryable();
                }
            }
            else
            {
                // Update database
                query = (await download()).AsQueryable();
            }
            return(query);
        }
예제 #8
0
 public DAL_CVehicle()
 {
     bdd = BddContext.GetInstance();
 }
예제 #9
0
 public DalFestival()
 {
     bdd = new BddContext();
 }
예제 #10
0
 public DAL_CRide()
 {
     bdd = BddContext.GetInstance();
 }
예제 #11
0
 public Dal(BddContext bdd)
 {
     _bdd = bdd;
     _bdd.Database.EnsureCreated();
 }
예제 #12
0
 public HomeController(BddContext context)
 {
     _context = context;
 }
예제 #13
0
 public DAL_CUser()
 {
     bdd = BddContext.GetInstance();
 }
예제 #14
0
 public AuteurEntityDal()
 {
     _context = new BddContext();
 }
예제 #15
0
 public ProprietairesController(BddContext context)
 {
     _context = context;
 }
예제 #16
0
 public AuteurDal()
 {
     _context = new BddContext();
 }
예제 #17
0
 public ClientDal()
 {
     _context = new BddContext();
 }
예제 #18
0
 public Dal()
 {
     bdd = new BddContext();
 }
예제 #19
0
 public MotClefsController(BddContext context)
 {
     _context = context;
 }
 public LiensController(BddContext context)
 {
     _context = context;
 }
예제 #21
0
 public LivreDal()
 {
     _context = new BddContext();
 }
예제 #22
0
 public Dal()
 {
     bdd = new BddContext();
 }
 public GamesController(BddContext context)
 {
     _context = context;
 }