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); }
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(); } }); }
/// <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(); } }
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()); }
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")); } } }
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(); }
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); }
public DAL_CVehicle() { bdd = BddContext.GetInstance(); }
public DalFestival() { bdd = new BddContext(); }
public DAL_CRide() { bdd = BddContext.GetInstance(); }
public Dal(BddContext bdd) { _bdd = bdd; _bdd.Database.EnsureCreated(); }
public HomeController(BddContext context) { _context = context; }
public DAL_CUser() { bdd = BddContext.GetInstance(); }
public AuteurEntityDal() { _context = new BddContext(); }
public ProprietairesController(BddContext context) { _context = context; }
public AuteurDal() { _context = new BddContext(); }
public ClientDal() { _context = new BddContext(); }
public Dal() { bdd = new BddContext(); }
public MotClefsController(BddContext context) { _context = context; }
public LiensController(BddContext context) { _context = context; }
public LivreDal() { _context = new BddContext(); }
public GamesController(BddContext context) { _context = context; }