public async Task <ActionResult <Bagage> > PostBagage(Bagage bagage)
        {
            _context.Bagages.Add(bagage);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetBagage", new { id = bagage.BagageId }, bagage));
        }
        public async Task <IActionResult> PutBagage(int id, Bagage bagage)
        {
            if (id != bagage.BagageId)
            {
                return(BadRequest());
            }

            _context.Entry(bagage).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BagageExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
 protected BagagePageModel(MyAirportContext context)
 {
     _context = context;
     Bagage   = new Bagage()
     {
         Vol = null
     };
 }
Exemplo n.º 4
0
 public void HandleBag(Bagage bag)
 {
     // Generates and tags a bag with a unique tag
     bag.BagTag = Tagger.GenTag();
     // notify server
     NotifyServer(bag, 2);
     // sendes videre til sorting
     Sendtosort(bag);
 }
Exemplo n.º 5
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bagage = await _context.Bagages.FirstOrDefaultAsync(m => m.BagageID == id);

            if (Bagage == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bagage = await _context.Bagages
                     .Include(b => b.Vol).FirstOrDefaultAsync(m => m.ID_BAGAGE == id);

            if (Bagage == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bagage = await _context.Bagages
                     .Include(b => b.Vol).FirstOrDefaultAsync(m => m.ID_BAGAGE == id);

            if (Bagage == null)
            {
                return(NotFound());
            }
            ViewData["ID_VOL"] = BagagesHelper.ListVolInfo(_context);
            return(Page());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bagage = await _context.Bagages.FindAsync(id);

            if (Bagage != null)
            {
                _context.Bagages.Remove(Bagage);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bagage = await _context.Bagages
                     .Include(b => b.Vol).FirstOrDefaultAsync(m => m.BagageId == id);

            if (Bagage == null)
            {
                return(NotFound());
            }
            ViewData["VolId"] = SelectListVols;
            return(Page());
        }
Exemplo n.º 10
0
        public async Task<IActionResult> OnGetAsync(int? id)
        {
            if (id == null)
            {
                return NotFound();
            }

            Bagage = await _context.Bagages.FirstOrDefaultAsync(m => m.BagageID == id);

            if (Bagage == null)
            {
                return NotFound();
            }

            ViewData["VolId"] = BagagesHelper.ListVolInfo(_context);

            return Page();
        }
Exemplo n.º 11
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Bagage = await _context.Bagages
                     .Include(b => b.Vol).FirstOrDefaultAsync(m => m.BagageId == id);

            if (Bagage == null)
            {
                return(NotFound());
            }
            //ViewData["VolId"] = new SelectList(_context.Vols, "VolId", "Cie");

            ViewData["VolId"] = BagageHelper.ListVolInfos(_context);

            return(Page());
        }
Exemplo n.º 12
0
 /// <summary>
 /// Recieving bags from Desk
 /// </summary>
 /// <param name="bag"></param>
 internal void RecieveFromDesk(Bagage bag)
 {
 }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            System.Console.WriteLine("MyAirport project bonjour!!");
            using (var db = new BNASNWEE.MyAirport.EF.MyAirportContext())
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    Cie = "LH",
                    Des = "BKK",
                    Dhc = Convert.ToDateTime("14/01/2020 16:45"),
                    Imm = "RZ62",
                    Lig = "1232",
                    Pkg = "R52",
                    Pax = 238
                };
                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    Cie = "SK",
                    Des = "CDG",
                    Dhc = Convert.ToDateTime("14/01/2020 18:20"),
                    Imm = "TG43",
                    Lig = "333",
                    Pkg = "R51",
                    Pax = 423
                };
                db.Add(v2);

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    Classe       = "Y",
                    CodeIata     = "012387364501",
                    DateCreation = Convert.ToDateTime("14/01/2020 12:52"),
                    Destination  = "BEG"
                };
                db.Add(b1);

                db.SaveChanges();
                Console.ReadLine();

                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.Cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VolId} a destination de {v.Des} part à {v.Dhc} heure");
                }
                Console.ReadLine();

                // Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                b1.VolId = v1.VolId;
                db.SaveChanges();
                Console.ReadLine();

                // Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
        }
Exemplo n.º 14
0
 /// <summary>
 /// Called when the bagage has been sorted
 /// </summary>
 /// <param name="bagage"></param>
 static void SortingOutgoingMessage(Bagage bagage)
 {
     CentralManager.Instance.FileLogger.Append($"[{bagage.Brand}] [{DateTime.Now}] sorted and going to gate: [{bagage.Sticker.GateId}]\n");
 }
Exemplo n.º 15
0
 internal void CreateBag(Bagage bag, int status)
 {
     Console.WriteLine($"I have added bag number: {bag.BagTag}. Destination: {bag.Destination}");
 }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            var connectionString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
            var optionsBuilder   = new DbContextOptionsBuilder <MyAirportContext>();

            optionsBuilder
            .UseSqlServer(connectionString)
            .UseLoggerFactory(MyLoggerFactory);

            ILogger logger = MyLoggerFactory.CreateLogger <Program>();

            System.Console.WriteLine("MyAirport project bonjour!!");
            using (var db = new MyAirportContext(optionsBuilder.Options))
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    Cie = "LH",
                    Des = "BKK",
                    Dhc = Convert.ToDateTime("14 January 2020 4:45:00 PM"),
                    Imm = "RZ62",
                    Lig = "1232",
                    Pkg = "R52",
                    Pax = 238
                };
                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    Cie = "SK",
                    Des = "CDG",
                    Dhc = Convert.ToDateTime("14 January 2020 6:45:00 PM"),
                    Imm = "TG43",
                    Lig = "333",
                    Pkg = "R51",
                    Pax = 423
                };
                db.Add(v2);

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    Classe       = "Y",
                    CodeIata     = "012387364501",
                    DateCreation = Convert.ToDateTime("14 January 2020 5:45:00 PM"),
                    Destination  = "BEG"
                };
                db.Add(b1);

                db.SaveChanges();
                Console.ReadLine();

                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols.OrderBy(v => v.Cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VolId} a destination de {v.Des} part à {v.Dhc} heure");
                }
                Console.ReadLine();

                // Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                b1.VolId = v1.VolId;
                db.SaveChanges();
                Console.ReadLine();

                // Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            dbContextOptionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyAirportDB"].ConnectionString);
            dbContextOptionsBuilder.UseLoggerFactory(MyAirportLoggerFactory);
            DbContextOptions <MyAirportContext> dbContextOptions = (DbContextOptions <MyAirportContext>)dbContextOptionsBuilder.Options;

            System.Console.WriteLine("MyAirport project bonjour!!");
            using (var db = new MyAirportContext(dbContextOptions))
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    Cie = "LH",
                    Des = "BKK",
                    Dhc = Convert.ToDateTime("14/01/2020 16:45"),
                    Imm = "RZ62",
                    Lig = "1232",
                    Pkg = "R52",
                    Pax = 238
                };
                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    Cie = "SK",
                    Des = "CDG",
                    Dhc = Convert.ToDateTime("14/01/2020 18:20"),
                    Imm = "TG43",
                    Lig = "333",
                    Pkg = "R51",
                    Pax = 423
                };
                db.Add(v2);

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    Classe       = "Y",
                    CodeIata     = "012387364501",
                    DateCreation = Convert.ToDateTime("14/01/2020 12:52"),
                    Destination  = "BEG"
                };
                db.Add(b1);

                db.Database.EnsureCreated();
                db.SaveChanges();
                Console.ReadLine();

                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.Cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VoldID} a destination de {v.Des} part à {v.Dhc} heure");
                }
                Console.ReadLine();

                // Update
                Console.WriteLine($"Le bagage {b1.BagageID} est modifié pour être rattaché au vol {v1.VoldID} => {v1.Cie}{v1.Lig}");
                b1.VolID = v1.VoldID;
                db.Database.EnsureCreated();
                db.SaveChanges();
                Console.ReadLine();

                // Delete vol et bagages du vol

                /*Console.WriteLine($"Suppression du vol {v1.VoldID} => {v1.Cie}{v1.Lig}");
                 * db.Remove(v1);
                 * db.Database.EnsureCreated();
                 * db.SaveChanges();
                 * Console.ReadLine();*/
            }
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            /***
             * Replace OnConfigure
             */
            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>();

            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyAirportDatabase"].ConnectionString);
            optionsBuilder.UseLoggerFactory(MyAirportLoggerFactory);

            DbContextOptions <MyAirportContext> optionDbContext = (DbContextOptions <MyAirportContext>)optionsBuilder.Options;

            using (var db = new MyAirportContext(optionDbContext))
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    cie = "LH",
                    des = "BKK",
                    dhc = Convert.ToDateTime("14/01/2020 16:45"),
                    imm = "RZ62",
                    lig = "1232",
                    pkg = "R52",
                    pax = 238
                };

                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    cie = "SK",
                    des = "CDG",
                    dhc = Convert.ToDateTime("14/01/2020 18:20"),
                    imm = "TG43",
                    lig = "333",
                    pkg = "R51",
                    pax = 423
                };
                db.Add(v2);

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    // VolId = v1.Vol,
                    classe        = "Y",
                    code_iata     = "012387364501",
                    date_creation = Convert.ToDateTime("14/01/2020 12:52"),
                    destination   = "BEG"
                };
                db.Add(b1);



                db.SaveChanges();
                Console.ReadLine();

                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols.OrderBy(v => v.cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.cie}{v.lig} N° {v.VolId} a destination de {v.des} part à {v.dhc} heure");
                }
                Console.ReadLine();



                //// Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au vol {v1.VolId} => {v1.cie}{v1.lig}");
                b1.VolId = v1.VolId;
                db.SaveChanges();
                Console.ReadLine();

                //// Delete vol et bagages du vol
                //    Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.cie}{v1.lig}");
                //   db.Remove(v1);
                // db.SaveChanges();
                //  Console.ReadLine();
            }
        }
Exemplo n.º 19
0
 private void NotifyServer(Bagage bag, int status)
 {
     // Notifies the server of a new bag wich is being send to sorting
     CentralServer.Instance.CreateBag(bag, status);
 }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            ILogger logger = MyLoggerFactoy.CreateLogger <Program>();

            logger.LogInformation("Logger initialized");
            var connectionString = ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;

            var optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>()
                                 .UseSqlServer(connectionString)
                                 .UseLoggerFactory(MyLoggerFactoy);

            Console.WriteLine("MyAirport project bonjour!!");
            using (var db = new MyAirportContext(optionsBuilder.Options))
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    Cie = "LH",
                    Des = "BKK",
                    Dhc = Convert.ToDateTime("01/14/2020 16:45"),
                    Imm = "RZ62",
                    Lig = "1232",
                    Pkg = "R52",
                    Pax = 238
                };
                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    Cie = "SK",
                    Des = "CDG",
                    Dhc = Convert.ToDateTime("01/14/2020 18:20"),
                    Imm = "TG43",
                    Lig = "333",
                    Pkg = "R51",
                    Pax = 423
                };
                db.Add(v2);

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    Classe       = "Y",
                    CodeIata     = "012387364501",
                    DateCreation = Convert.ToDateTime("01/14/2020 12:52"),
                    Destination  = "BEG"
                };
                db.Add(b1);

                db.SaveChanges();
                Console.ReadLine();

                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.Cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VolID} a destination de {v.Des} part à {v.Dhc} heure");
                }
                Console.ReadLine();

                // Update
                Console.WriteLine($"Le bagage {b1.BagageID} est modifié pour être rattaché au vol {v1.VolID} => {v1.Cie}{v1.Lig}");
                b1.Vol = v1;
                db.SaveChanges();
                v1.Bagages.ToList().ForEach(b =>
                {
                    Console.WriteLine($"Le bagage {b.BagageID} est associé au vol {b.Vol.VolID}.");
                });
                Vol vod = v1;
                Console.WriteLine("#####################################################");
                Console.WriteLine(vod.VolID);
                vod.Bagages.ToList().ForEach(bag => Console.WriteLine(bag.BagageID));
                Console.WriteLine("#####################################################");
                Console.ReadLine();

                // Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VolID} => {v1.Cie}{v1.Lig}");
                //db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>();

            optionsBuilder.UseLoggerFactory(MyAirportLoggerFactory);
            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyAirportDatabase"].ConnectionString);
            System.Console.WriteLine("MyAirport project bonjour!!");
            using (var db = new MyAirportContext(optionsBuilder.Options)
                            //var db = new MyAirportContext()
                   )
            {
                //Clear db to begin
                var bag = db.Bagages;
                foreach (var b in bag)
                {
                    db.Remove(b);
                }


                var vol = db.Vols;
                foreach (var v in vol)
                {
                    db.Remove(v);
                }
                db.SaveChanges();


                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    Cie = "LH",
                    Des = "BKK",
                    Dhc = Convert.ToDateTime("14/01/2020 16:45"),
                    Imm = "RZ62",
                    Lig = "1232",
                    Pkg = "R52",
                    Pax = 238
                };
                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    Cie = "SK",
                    Des = "CDG",
                    Dhc = Convert.ToDateTime("14/01/2020 18:20"),
                    Imm = "TG43",
                    Lig = "333",
                    Pkg = "R51",
                    Pax = 423
                };
                db.Add(v2);

                Console.WriteLine("Creation vol BKK238");
                db.Add(new Vol("LH", "1234", Convert.ToDateTime("18/03/2020 16:45"))
                {
                    Des = "BKK",
                    Imm = "RB22",
                    Pkg = "R52",
                    Pax = 238
                }
                       );
                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    Classe       = "Y",
                    CodeIata     = "012387364501",
                    DateCreation = Convert.ToDateTime("14/01/2020 12:52"),
                    Destination  = "BEG"
                };
                db.Add(b1);

                Console.WriteLine("creation du bagage 987654321");
                Bagage b2 = new Bagage
                {
                    Classe       = "Y",
                    CodeIata     = "987654321",
                    DateCreation = Convert.ToDateTime("12/04/2020 17:18"),
                    Destination  = "BEG"
                };
                db.Add(b2);

                Console.WriteLine("creation du bagage 0123456789");
                db.Add(new Bagage("0123456789", Convert.ToDateTime("17/03/2020 14:09"))
                {
                    Classe      = "Y",
                    Destination = "BEG"
                });



                db.SaveChanges();
                Console.ReadLine();

                // ReadBagages_Vols_VolI
                Console.WriteLine("Voici la liste des vols disponibles");
                var vols = db.Vols
                           .OrderBy(v => v.Cie);
                foreach (var v in vols)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VolId} a destination de {v.Des} part à {v.Dhc} heure");
                }
                Console.ReadLine();

                // Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                b1.VolId = v1.VolId;
                db.SaveChanges();
                v1.Bagages.ToList().ForEach(b => Console.WriteLine($"VOLID: {v1.VolId} -> bagage {b.BagageId}"));
                Console.ReadLine();

                // Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au vol {v2.VolId} => {v2.Cie}{v2.Lig}");
                b2.VolId = v2.VolId;
                db.SaveChanges();
                v1.Bagages.ToList().ForEach(b => Console.WriteLine($"VOLID: {v2.VolId} -> bagage {b.BagageId}"));
                Console.ReadLine();

                // Delete vol et mise a null du volId dans bagage
                Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();

                // Delete vol et delete des bagages attribués à ce vol
                Console.WriteLine($"Suppression du vol {v2.VolId} => {v2.Cie}{v2.Lig} induisant suppression du bagage {b2.BagageId} ");
                var bagages = db.Bagages.Where(b => b.VolId == v2.VolId);

                foreach (var b in bagages)
                {
                    db.Remove(b);
                }
                db.Remove(v2);
                db.SaveChanges();

                Console.ReadLine();
            }
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>();

            optionsBuilder.UseLoggerFactory(MyAirportLoggerFactory);
            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyAirportContext"].ConnectionString);



            System.Console.WriteLine("MyAirport project bonjour!!");
            using (var db = new MyAirportContext(optionsBuilder.Options))
            //using (var db = new MyAirportContext())
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol("LH", "1232", Convert.ToDateTime("14/01/2020 16:45"))
                {
                    Des = "BKK",
                    Imm = "RZ62",
                    Pkg = "R52",
                    Pax = 238
                };
                db.Add(v1);
                db.SaveChanges();

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol("SK", "333", Convert.ToDateTime("14/01/2020 18:20"))
                {
                    Des = "CDG",
                    Imm = "TG43",
                    Pkg = "R51",
                    Pax = 423
                };
                db.Add(v2);

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage("012387364501", Convert.ToDateTime("14/01/2020 12:52"))
                {
                    Classe      = "Y",
                    Destination = "BEG",
                };
                db.Add(b1);

                db.SaveChanges();
                Console.ReadLine();

                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.Cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VolId} a destination de {v.Des} part à {v.Dhc} heure");
                }
                Console.ReadLine();



                // Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                b1.VolId = v1.VolId;
                db.SaveChanges();
                Console.ReadLine();

                Console.WriteLine($"Il y a {v1.Bagages.Count()}  bagages sur le vol {v1.VolId}");

                // Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello!");



            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>();

            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyAirport"].ConnectionString);
            ///On utilise la factory pour gérer les logs

            optionsBuilder.UseLoggerFactory(MyLoggerFactory);

            System.Console.WriteLine("MyAirport project bonjour!!");
            DbContextOptions <MyAirportContext> myOptions = (DbContextOptions <MyAirportContext>)optionsBuilder.Options;

            using (var db = new MyAirportContext(myOptions))
            {
                //// Create
                //System.Console.WriteLine("Création du vol LH1232");
                //Vol v1 = new Vol
                //{
                //    CIE = 1,
                //    DES = "BKK",
                //    DHC = Convert.ToDateTime("14/01/2020 16:45"),
                //    IMM = "eer",
                //    LIG = "1232",
                //    PKG = "r",
                //    PAX = 238
                //};
                //db.Add(v1);

                //System.Console.WriteLine("Creation vol SQ333");
                //Vol v2 = new Vol
                //{
                //    CIE = 1,
                //    DES = "CDG",
                //    DHC = Convert.ToDateTime("14/01/2020 18:20"),
                //    IMM = "TG43",
                //    LIG = "333",
                //    PKG = "R51",
                //    PAX = 423
                //};
                //db.Add(v2);

                System.Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    CLASSE        = "Y",
                    CODE_IATA     = "012387364501",
                    DATA_CREATION = Convert.ToDateTime("14/01/2020 12:52"),
                    DESTINATION   = "BEG",
                    VolID         = 1
                };
                db.Add(b1);

                db.SaveChanges();
                System.Console.ReadLine();
                System.Console.WriteLine("Voici la liste des bagages disponibles");
                var bags = db.Bagage
                           .OrderBy(b => b.CODE_IATA);
                foreach (var b in bags)
                {
                    System.Console.WriteLine($"Le bagage {b.DATA_CREATION} heure");
                }
                System.Console.ReadLine();
                // Read
                System.Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vol
                          .OrderBy(v => v.CIE);
                foreach (var v in vol)
                {
                    System.Console.WriteLine($"Le vol {v.DHC} ");//{v.CIE}{v.LIG} N° {v.VolID} a destination de {v.DES} part à {v.DHC} heure");
                }
                System.Console.ReadLine();


                //// Update
                //System.Console.WriteLine($"Le bagage {b1.BagageID} est modifié pour être rattaché au vol {v1.VolID} => {v1.CIE}{v1.LIG}");
                //b1.VolID = v1.VolID;
                //db.SaveChanges();
                //System.Console.ReadLine();

                //// Delete vol et bagages du vol
                //System.Console.WriteLine($"Suppression du vol {v1.VolID} => {v1.CIE}{v1.LIG}");
                //db.Remove(v1);
                //db.SaveChanges();
                //System.Console.ReadLine();
            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("MyAirport project bonjour!!");

            var optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>();

            //optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Airport;Integrated Security=True");
            optionsBuilder.UseLoggerFactory(MyAirportLoggerFactory);

            using (var db = new MyAirportContext(optionsBuilder.Options))
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    CIE = @"LH",
                    DES = @"BKK",
                    DHC = Convert.ToDateTime("14/01/2020 16:45"),
                    IMM = "RZ62",
                    LIG = "1232",
                    PKG = "R52",
                    PAX = 238
                };
                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    CIE = "SK",
                    DES = "CDG",
                    DHC = Convert.ToDateTime("14/01/2020 18:20"),
                    IMM = "TG43",
                    LIG = "333",
                    PKG = "R51",
                    PAX = 423
                };
                db.Add(v2);
                db.SaveChanges();

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    //VolID = v2.VolId,
                    Classe       = "Y",
                    CodeIata     = "012387364501",
                    DateCreation = Convert.ToDateTime("14/01/2020 12:52"),
                    Destination  = "BEG"
                };
                db.Add(b1);

                db.SaveChanges();
                Console.ReadLine();

                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.CIE);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.CIE}{v.LIG} N° {v.VolId} a destination de {v.DES} part à {v.DHC} heure");
                }
                Console.ReadLine();

                // Update
                //Console.WriteLine($"Le bagage {b1.BagageID} est modifié pour être rattaché au vol {v1.VolId} => {v1.CIE}{v1.LIG}");
                Console.WriteLine($"Le bagage {b1.BagageID} est modifié pour être rattaché au vol {v2.VolId} => {v2.CIE}{v2.LIG}");

                b1.VolID = v2.VolId;
                db.SaveChanges();
                Console.ReadLine();

                // Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.CIE}{v1.LIG}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
        }
Exemplo n.º 25
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <AirportContext>();

            optionsBuilder.UseLoggerFactory(MyLoggerFactory);
            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["AirportDB"].ConnectionString);

            using (var db = new AirportContext(optionsBuilder.Options))
            {
                //CREATE
                var vol = new Vol {
                    CIE = "vol",
                    LIG = "air"
                };
                db.Vols.Add(vol);
                db.SaveChanges();

                // Read
                var vol1 = db.Vols
                           .First();

                var baggage = new Bagage
                {
                    ID_VOL        = vol1.ID_VOL,
                    CODE_IATA     = "QSDSQD",
                    DATE_CREATION = new DateTime(2012, 12, 25, 10, 30, 50)
                };
                db.Bagages.Add(baggage);
                db.SaveChanges();

                var baggage2 = new Bagage
                {
                    ID_VOL        = vol1.ID_VOL,
                    CODE_IATA     = "FDSFZ",
                    DATE_CREATION = new DateTime(2012, 12, 25, 10, 30, 50)
                };
                db.Bagages.Add(baggage2);
                db.SaveChanges();

                // Read
                var bag = db.Bagages
                          .First();

                // Update
                bag.CODE_IATA = "FSDFA";
                bag.SSUR      = "SDFDSS";
                db.SaveChanges();

                // Delete
                db.Remove(bag);


                // Read
                var voll = db.Vols
                           .First();

                Console.WriteLine(voll.Bagages.Count);



                db.SaveChanges();
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Called when the counter registers a bagage
 /// </summary>
 /// <param name="bagage"></param>
 /// <param name="desk"></param>
 static void CounterMessage(Bagage bagage, CounterDesk desk)
 {
     CentralManager.Instance.FileLogger.Append($"[{bagage.Brand}] [{DateTime.Now}] [{desk.GateId}] Checked In\n");
 }
Exemplo n.º 27
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            DbContextOptionsBuilder optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>();

            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["MyAirport"].ConnectionString);
            optionsBuilder.UseLoggerFactory(MyAirportLoggerFactory);
            DbContextOptions <MyAirportContext> dbContextOptions = (DbContextOptions <MyAirportContext>)optionsBuilder.Options;

            using (var db = new MyAirportContext(dbContextOptions))
            {
                // Create
                Console.WriteLine("Création du vol TUNISIE123");

                Vol v1 = new Vol()
                {
                    CIE = "TUNISIE",
                    DES = "PARIS",
                    DHC = Convert.ToDateTime("14/01/2020 16:45"),
                    IMM = "RZ62",
                    LIG = "123",
                    PKG = "R52",
                    PAX = 238
                };
                db.Vols.Add(v1);
                db.SaveChanges();

                Console.WriteLine(v1.CIE);
                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    //VOLID = 14,
                    CLASSE        = "Y",
                    CODE_IATA     = "012387364501",
                    DATA_CREATION = Convert.ToDateTime("14/01/2020 12:52"),
                    DESTINATION   = "BEG"
                };
                db.Bagages.Add(b1);
                db.SaveChanges();

                Console.ReadLine();

                // Read

                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.CIE);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.CIE}{v.LIG} N° {v.VOLID} a destination de {v.DES} part à {v.DHC} heure");
                }
                Console.ReadLine();
                // Update
                // b1.CODE_IATA = "TREZA";
                //b1.SSUR = "AZE";
                Console.WriteLine($"Le bagage {b1.BAGAGEID} est modifié pour être rattaché au vol {v1.VOLID} => {v1.CIE}{v1.LIG}");
                b1.VOLID = v1.VOLID;
                db.SaveChanges();


                // Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VOLID} => {v1.CIE}{v1.LIG}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
        }
Exemplo n.º 28
0
 /// <summary>
 /// Called when a bagage is about to be sorted
 /// </summary>
 /// <param name="bagage"></param>
 static void SortingIngoingMessage(Bagage bagage)
 {
     CentralManager.Instance.FileLogger.Append($"[{bagage.Brand}] [{DateTime.Now}] about to be sorted\n");
 }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            var logger = MyAirportContext.loggerFactory.CreateLogger <Program>();

            System.Console.WriteLine("MyAirport project bonjour!!");
            using (var db = new MyAirportContext())
            {
                // Create
                Console.WriteLine("Création du vol LH1232");
                Vol v1 = new Vol
                {
                    Cie             = "LH",
                    Destination     = "BKK",
                    Dhc             = Convert.ToDateTime("14/01/2020 16:45"),
                    Immatriculation = "RZ62",
                    Lig             = "1232",
                    Parking         = "R52",
                    NbPassagers     = 238
                };
                db.Add(v1);

                Console.WriteLine("Creation vol SQ333");
                Vol v2 = new Vol
                {
                    Cie             = "SK",
                    Destination     = "CDG",
                    Dhc             = Convert.ToDateTime("14/01/2020 18:20"),
                    Immatriculation = "TG43",
                    Lig             = "333",
                    Parking         = "R51",
                    NbPassagers     = 423
                };
                db.Add(v2);

                Console.WriteLine("creation du bagage 012387364501");
                Bagage b1 = new Bagage
                {
                    Classe       = "Y",
                    CodeIata     = "012387364501",
                    DateCreation = DateTime.Now,
                    Destination  = "BEG",
                    Escale       = "Paris",
                    SSUR         = "SSUR",
                    Sta          = "Sta",
                    Prioritaire  = 1
                };
                db.Add(b1);

                db.SaveChanges();
                Console.ReadLine();

                logger.LogInformation("Example log message create");

                //Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.Cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VolId} a destination de {v.Destination} part à {v.Dhc} heure");
                }
                Console.ReadLine();

                //Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au ");
                b1.VolId = v1.VolId;
                db.SaveChanges();
                Console.ReadLine();


                //Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
        }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <MyAirportContext>();

            optionsBuilder.UseLoggerFactory(MyLoggerFactory);
            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["Airport"].ConnectionString);

            using (var db = new MyAirportContext(optionsBuilder.Options))
//            using (var db = new MyAirportContext())
            {
                // Create
                Console.WriteLine("Création du vol LH1232");

                /*Vol v1 = new Vol
                 * {
                 *  Cie = "LH",
                 *  Des = "BKK",
                 *  Dhc = Convert.ToDateTime("14/01/2020 16:45"),
                 *  Imm = "RZ62",
                 *  Lig = "1232",
                 *  Pkg = "R52",
                 *  Pax = 238
                 * };*/
                Vol v1 = new Vol("LH", "1232", DateTime.Now)
                {
                    Des = "BKK"
                };
                db.Add(v1);

                Console.WriteLine("creation du bagage 012387364501");

                /*Bagage b1 = new Bagage
                 * {
                 *  Classe = "Y",
                 *  CodeIata = "012387364501",
                 *  DateCreation = Convert.ToDateTime("14/01/2020 12:52"),
                 *  Destination = "BEG"
                 * }; */
                Bagage b1 = new Bagage("012387364501", DateTime.Now)
                {
                    Destination = "BKK"
                };
                db.Add(b1);

                db.SaveChanges();
                Console.ReadLine();


                // Read
                Console.WriteLine("Voici la liste des vols disponibles");
                var vol = db.Vols
                          .OrderBy(v => v.Cie);
                foreach (var v in vol)
                {
                    Console.WriteLine($"Le vol {v.Cie}{v.Lig} N° {v.VolId} a destination de {v.Des} part à {v.Dhc} heure");
                }
                Console.ReadLine();

                // Update
                Console.WriteLine($"Le bagage {b1.BagageId} est modifié pour être rattaché au vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                //b1.VolId = v1.VolId;
                db.SaveChanges();
                Console.ReadLine();

                // Delete vol et bagages du vol
                Console.WriteLine($"Suppression du vol {v1.VolId} => {v1.Cie}{v1.Lig}");
                db.Remove(v1);
                db.SaveChanges();
                Console.ReadLine();
            }
            Console.WriteLine("Hello World!");
        }