Beispiel #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));
        }
Beispiel #2
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());
        }
Beispiel #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();
            }
        }
Beispiel #4
0
        public MessagingResponse GetResponse(string messageBody, string messagePhone)
        {
            //Recoit Un message et le numero de telephone, Si le message correspont au norme et est trouver,
            //un MessageStatus.Closed/MessageStatus.Follow  est appliquer sinon envoie un erreur

            var answer = new Message();

            if (messageBody.Length > 5 &&
                (messageBody.ToUpper().StartsWith(_InputMessages[0]) || messageBody.ToUpper().StartsWith(_InputMessages[1])))
            {
                string flight_id = messageBody.ToUpper().Substring(5);
                if (Regex.IsMatch(flight_id, NotificationApp.NumVolRegex))
                {
                    Notification notif = DB2.Aeroport().Notifications.SingleOrDefault(m => m.Num_Phone == messagePhone);

                    MessageStatus status = (notif != null) ? MessageStatus.Closed : MessageStatus.Error;
                    string        result = MessageDistributor(status, notif);
                    answer.Body(result);

                    //If status is Closed then set to True
                    if (status == MessageStatus.Closed)
                    {
                        db.Entry(notif).Property(u => u.Statut).CurrentValue = true;
                    }
                }
                else
                {
                    answer.Body(MessageDistributor(MessageStatus.Error));
                }
            }
            else if (messageBody.Length > 5 &&
                     (messageBody.ToUpper().StartsWith(_InputMessages[2]) || messageBody.ToUpper().StartsWith(_InputMessages[3])))
            {
                string flight_id = messageBody.ToUpper().Substring(5);
                if (Regex.IsMatch(flight_id, NotificationApp.NumVolRegex))
                {
                    Notification notif = db.Notifications.SingleOrDefault(m => m.Num_Phone == messagePhone);

                    MessageStatus status = (notif != null) ? MessageStatus.Followed : MessageStatus.Error;
                    string        result = MessageDistributor(status, notif);
                    answer.Body(result);

                    //If status is Followed then set to False
                    if (status == MessageStatus.Followed)
                    {
                        db.Entry(notif).Property(u => u.Statut).CurrentValue = false;
                    }
                }
                else
                {
                    answer.Body(MessageDistributor(MessageStatus.Error));
                }
            }
            else
            {
                answer.Body(MessageDistributor(MessageStatus.Error));
            }


            var messageResponce = new MessagingResponse();

            messageResponce.Append(answer);
            return(messageResponce);
        }