Ejemplo n.º 1
0
        public IHttpActionResult PutVille(int id, Ville ville)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ville.Id_Ville)
            {
                return(BadRequest());
            }

            db.Entry(ville).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VilleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 2
0
        private bool Retire()
        {
            int itemsToDequeue = retirePhoneList.Count;

            using (db = DB2.Aeroport())
            {
                try
                {
                    while (itemsToDequeue-- > 0)
                    {
                        Notification item;
                        bool         isTaken = retirePhoneList.TryDequeue(out item);

                        if (isTaken)
                        {
                            var dbelem = db.Notifications.Find(item.Id);
                            if (dbelem != null)
                            {
                                twilloInstance.WriteNewNotification(item);
                                item.Statut = true;
                            }
                            else
                            {
                                notFoundPhoneList.Enqueue(item);
                            }
                        }
                        else
                        {
                            if (retirePhoneList.IsEmpty)
                            {
                                db.SaveChanges();
                                return(true);
                            }
                        }
                    }
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        public void verifyNotification()
        {
            DateTime            todayOffset = DateTime.Now.AddDays(-2);
            List <Notification> notifList;

            using (db = DB2.Aeroport())
            {
                notifList = db.Notifications.ToList();
                notifList.ForEach((m) =>
                {
                    if (m.Date_Notification.CompareTo(todayOffset) < 0 && m.Statut != true)
                    {
                        db.Entry(m).Property(u => u.Statut).CurrentValue = true;
                    }
                });

                db.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public void MAJVolsCedules()
        {
            List <VolsCedule> vols = new List <VolsCedule>(LoadJson());

            using (db = DB2.Aeroport())
            {
                try
                {
                    for (int i = 0; i < vols.Count; i++)
                    {
                        string     num = vols[i].Numero_Vol;
                        VolsCedule vol = db.VolsCedules.SingleOrDefault(m => m.Numero_Vol == num);

                        if (vol != null)
                        {
                            vols[i].Id_Date_Depart = vol.Id_Date_Depart;
                            bool IsEqual = vol.IsEqual(vols[i]);
                            if (!IsEqual)
                            {
                                vol.Date_Depart_Revisee  = vols[i].Date_Depart_Revisee;
                                vol.Date_Arrivee_Revisee = vols[i].Date_Arrivee_Revisee;
                                vol.Etat   = vols[i].Etat;
                                vol.Statut = vols[i].Statut;
                            }
                            else
                            {
                                vols.Remove(vols[i]);
                            }
                        }
                    }

                    db.SaveChanges();
                    UpdateNotification(vols);
                }
                catch (Exception e) {
                    return;
                }
            }
        }
Ejemplo n.º 5
0
        private VolsCedule[] LoadJson()
        {
            List <VolsCedule> items;

            using (StreamReader r = new StreamReader(_FILELOCATION))
            {
                string json = r.ReadToEnd();
                items = new List <VolsCedule>(JsonConvert.DeserializeObject <VolsCedule[]>(json));
            }

            using (db = DB2.Aeroport())
            {
                try
                {
                    items.ForEach((item) =>
                    {
                        VolsCedule vol = db.VolsCedules.FirstOrDefault(m => m.Numero_Vol == item.Numero_Vol);
                        if (vol != null)
                        {
                            db.Entry(vol).Property(u => u.Date_Arrivee_Revisee).CurrentValue = item.Date_Arrivee_Revisee;
                            db.Entry(vol).Property(u => u.Date_Depart_Revisee).CurrentValue  = item.Date_Depart_Revisee;
                            db.Entry(vol).Property(u => u.Etat).CurrentValue           = item.Etat;
                            db.Entry(vol).Property(u => u.Statut).CurrentValue         = item.Statut;
                            db.Entry(vol).Property(u => u.Id_Date_Depart).CurrentValue = item.Id_Date_Depart;
                        }
                    });
                    if (items.Count > 0)
                    {
                        db.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                }
            }

            return(items.ToArray());
        }