예제 #1
0
        public async Task <PartialViewResult> AddPartialBook(Livre livre)
        {
            if (ModelState.IsValid)
            {
                string isbnString = livre.ISBN.ToString();

                string title = "", auteur = "", editionDate = "", image = "", description = "";
                double price = 0.0, nbrePoints = 0.0, avancePoints = 0.0;
                try
                {
                    title = await service.GetTitle(isbnString);

                    price = await service.GetPrice(isbnString);

                    nbrePoints   = service.GetPoints(price, EtatDuLivre.COMMENEUF);
                    avancePoints = service.GetPoints(price, EtatDuLivre.COMMENEUF, livre.IsExchange);
                    editionDate  = await service.GetDateEdition(isbnString);

                    image = await service.GetImage(isbnString);

                    description = await service.GetDescription(isbnString);

                    auteur = await service.GetAuthors(isbnString);
                }
                catch (BookNotFoundException bookException)
                {
                    ViewBag.ExceptionBook = bookException.Message;
                    return(PartialView());
                }
                livre.Author       = auteur;
                livre.ISBN         = Convert.ToInt64(isbnString);
                livre.Title        = title;
                livre.Image        = image;
                livre.Description  = description;
                livre.Price        = price;
                livre.PointDuLivre = nbrePoints;
                livre.AvancePoints = avancePoints;
                livre.DateEdition  = editionDate;

                /*                livre.DateEdition = DateTime.Parse(editionDate).Year;
                 */

                LivreCategorieViewModel viewModel = new LivreCategorieViewModel();
                viewModel.Livre = livre;

                viewModel.Categories = contextCategory.Collection().ToList();


                return(PartialView("_BookInfos", viewModel));
            }
            else
            {
                return(PartialView());
            }

            /*            string author = service.GetEdithor(isbnString);
             *          string editionDate = service.GetDateEdition(isbnString);
             *          string langauge = service.GetLanguage(isbnString);
             *          int volume = service.GetVolume(isbnString);
             *          List<string> categories = service.GetCategories(isbnString);
             *          string dimension = service.GetDimension(isbnString);
             *          string description = service.GetDescription(isbnString);
             *          double criticalBook = service.GetAverageRatingCritical(isbnString);
             */


            //Calcul du nombre de points
        }
예제 #2
0
 public void removeart(Livre art)
 {
     db.Livre.Remove(art);
     db.SaveChanges();
 }
예제 #3
0
        public ActionResult SubmitCreationLivre(string Titre, string Auteur)
        {
            Livre nouvoLivre = new Livre(0, Titre, Auteur, null, DateTime.Now, null);

            return(View());
        }
        public static void Main(string[] args)
        {
            // Afficher la liste des prénoms des auteurs dont le nom commence par "G"

            //Data.Instance.ListeAuteurs.Where(a => a.Nom.Substring(0, 1).Equals("G"));
            //List<Auteur> auteursQ1 = Data.Instance.ListeAuteurs
            //    .Where(a => a.Nom.StartsWith("G")).ToList();
            List <String> prenomAuteurQ1 = Data.Instance.ListeAuteurs
                                           .Where(a => a.Nom.Substring(0, 1).Equals("G"))
                                           .Select(a => a.Prenom).ToList();

            Console.WriteLine("Q1 :");

            foreach (var prenomAuteur in prenomAuteurQ1)
            {
                Console.WriteLine(prenomAuteur);
            }

            Console.ReadKey();
            Console.WriteLine();

            //Afficher l’auteur ayant écrit le plus de livres
            IGrouping <Auteur, Livre> auteurQ2 = Data.Instance.ListeLivres
                                                 .GroupBy(l => l.Auteur)
                                                 .OrderByDescending(g => g.Count())
                                                 .FirstOrDefault();

            Console.WriteLine("Q2 :");
            Console.WriteLine($"{auteurQ2.Key.Nom} {auteurQ2.Key.Prenom}");

            Console.ReadKey();
            Console.WriteLine();

            //Afficher le nombre moyen de pages par livre par auteur
            Console.WriteLine("Q3 :");
            foreach (var groupingAuteurLivre in Data.Instance.ListeLivres.GroupBy(l => l.Auteur))
            {
                Console.WriteLine($"{groupingAuteurLivre.Key.Nom} {groupingAuteurLivre.Key.Prenom}");
                Console.WriteLine($"Moyenne des pages = {groupingAuteurLivre.Average(l => l.NbPages)}");
            }

            Console.ReadKey();
            Console.WriteLine();

            //Afficher le titre du livre avec le plus de pages
            //Data.Instance.ListeLivres.Max(x => x.NbPages)
            Livre livreQ4 = Data.Instance.ListeLivres.OrderByDescending(l => l.NbPages).FirstOrDefault();

            Console.WriteLine("Q4 :");
            Console.WriteLine($"Livre avec le maximum de page : {livreQ4.Titre}");

            Console.ReadKey();
            Console.WriteLine();

            //Afficher combien ont gagné les auteurs en moyenne (moyenne des factures)
            decimal moyenneQ5 = Data.Instance.ListeAuteurs
                                .Average(a => a.Factures.Sum(f => f.Montant));

            Console.WriteLine("Q5 :");
            Console.WriteLine($"Moyenne des sommes gagnés par les auteurs : {moyenneQ5}");

            Console.ReadKey();
            Console.WriteLine();

            //Afficher les auteurs et la liste de leurs livres
            //foreach (var item in Data.Instance.ListeAuteurs)
            //{
            //    foreach (var livre in Data.Instance.ListeLivres)
            //    {
            //        if (livre.Auteur.Equals(item))
            //        {

            //        }
            //    }
            //}

            Console.WriteLine("Q6 :");
            var groupingAuteurLivreQ6s = Data.Instance.ListeLivres.GroupBy(l => l.Auteur);

            foreach (var auteurAvecLivres in groupingAuteurLivreQ6s)
            {
                Console.WriteLine($"{auteurAvecLivres.Key.Nom} {auteurAvecLivres.Key.Prenom}");
                foreach (var livre in auteurAvecLivres)
                {
                    Console.WriteLine($"Livre : {livre.Titre}");
                }
            }

            Console.ReadKey();
            Console.WriteLine();

            // Afficher les titres de tous les livres triés par ordre alphabétique
            Console.WriteLine("Q7 :");
            List <String> titreQ7s = Data.Instance.ListeLivres.Select(l => l.Titre).OrderBy(t => t).ToList();

            foreach (var item in titreQ7s)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();

            titreQ7s.ForEach((s) =>
            {
                Console.WriteLine(s);
            });

            Console.WriteLine();
            titreQ7s.ForEach(Console.WriteLine);

            Console.ReadKey();
            Console.WriteLine();

            // Afficher la liste des livres dont le nombre de pages est supérieur à la moyenne
            double nbPageMoyenneQ8 = Data.Instance.ListeLivres.Average(l => l.NbPages);

            //List<Livre> livresQ8 = Data.Instance.ListeLivres.Where(l => l.NbPages > nbPageMoyenneQ8).ToList();

            Console.WriteLine("Q8 :");
            Data.Instance.ListeLivres.Where(l => l.NbPages > nbPageMoyenneQ8)
            .ToList().ForEach((l) =>
            {
                Console.WriteLine(l.Titre);
            });

            Console.ReadKey();
            Console.WriteLine();

            // Afficher l'auteur ayant écrit le moins de livres
            Console.WriteLine("Q9 :");
            Auteur auteurQ9 = Data.Instance.ListeAuteurs
                              .OrderBy(a => Data.Instance.ListeLivres.Count(l => l.Auteur == a))
                              .FirstOrDefault();

            Console.WriteLine($"{auteurQ9.Nom} {auteurQ9.Prenom}");

            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            //Ajout Biblotheque
            Bibliotheque b = new Bibliotheque()
            {
                NbrDoc = 100
            };
            IBibliothequeService bibliothequeser = new BibliothequeService();

            bibliothequeser.Add(b);
            bibliothequeser.Commit();
            //Ajout 3 Livres
            Document D = new Livre()
            {
                Categorie = "informatique", Titre = "C# pour les debutants", nbrdepage = 157, Etat = Etat.Disponible, BibliothequeFK = 1
            };
            Document D1 = new Livre()
            {
                Categorie = "informatique", Titre = "Developper en .NET", nbrdepage = 209, Etat = Etat.Emprunte, BibliothequeFK = 1
            };
            Document D2 = new Livre()
            {
                Categorie = "informatique", Titre = "UML 2.0", nbrdepage = 358, Etat = Etat.Disponible, BibliothequeFK = 1
            };
            IDocumetService LS = new DocumentService();

            LS.Add(D);
            LS.Add(D1);
            LS.Add(D2);

            //Ajout 3 CD
            Document cd1 = new CD()
            {
                Categorie = "scientifique", Titre = "science de la vie et de la terre", NbreDePlage = 5, Duree = new TimeSpan(10, 10, 10), Etat = Etat.Disponible, BibliothequeFK = 1
            };
            Document cd2 = new CD()
            {
                Categorie = "education", Titre = "parler en francais", NbreDePlage = 12, Duree = new TimeSpan(08, 10, 50), Etat = Etat.Emprunte, BibliothequeFK = 1
            };
            Document cd3 = new CD()
            {
                Categorie = "litterature", Titre = "le Rouge et le noir", NbreDePlage = 8, Duree = new TimeSpan(12, 10, 10), Etat = Etat.Disponible, BibliothequeFK = 1
            };

            LS.Add(cd1);
            LS.Add(cd2);
            LS.Add(cd3);

            LS.Commit();
            Console.WriteLine("----------------------------Affichages des livres--------------------------------------");
            foreach (var item in LS.GetAll().OfType <Livre>())
            {
                Console.WriteLine("les Livres:" + item.Titre + "  " + item.Categorie + "  " + item.nbrdepage + " " + item.Etat);
            }
            Console.WriteLine("-----------------------------Affichage des CDs-----------------------------------------");
            foreach (var item in LS.GetAll().OfType <CD>())
            {
                Console.WriteLine("LES CD :" + item.Categorie + " " + item.Titre + " " + item.NbreDePlage + " " + item.Etat);
            }
            //Ajout des professeurs
            Professeur professeur = new Professeur()
            {
                nomComplet = new NomComplet()
                {
                    Nom = "Ahmed", Prenom = "ben salem"
                }, Departement = "TIC", Salaire = 1200, Image = "ff", Email = "*****@*****.**", nbAvertissement = 3, MotDePasse = "123456", ConfirmMotDePasse = "123456", DateDePriseDeFonction = new DateTime(2018, 01, 22)
            };
            Professeur professeur1 = new Professeur()
            {
                nomComplet = new NomComplet()
                {
                    Nom = "cyrine", Prenom = "slimen"
                },
                Departement           = "TIC",
                Salaire               = 1400f,
                Image                 = "ff",
                Email                 = "*****@*****.**",
                nbAvertissement       = 3,
                MotDePasse            = "123456",
                ConfirmMotDePasse     = "123456",
                DateDePriseDeFonction = new DateTime(2018, 08, 22)
            };
            Professeur professeur2 = new Professeur()
            {
                nomComplet = new NomComplet()
                {
                    Nom = "Amine", Prenom = "ben said"
                },
                Departement           = "TIC",
                Salaire               = 1000f,
                Image                 = "ff",
                Email                 = "*****@*****.**",
                nbAvertissement       = 3,
                MotDePasse            = "123456",
                ConfirmMotDePasse     = "123456",
                DateDePriseDeFonction = new DateTime(2017, 08, 22)
            };
            IProfesseurService ps = new ProfesseurService();

            ps.Add(professeur);
            ps.Add(professeur1);
            ps.Add(professeur2);
            ps.Commit();
            Console.WriteLine("-------------------------------------------Affichage des profs-------------------------");
            foreach (var item in ps.GetAll())
            {
                Console.WriteLine("les Profs : " + item.nomComplet.Nom + "  " + item.Salaire + " " + item.nbAvertissement);
            }
            //Ajout des etudiants
            Etudiant Etud = new Etudiant()
            {
                nomComplet = new NomComplet()
                {
                    Nom = "sami", Prenom = "ben salem"
                },
                Filiere           = "BI",
                Image             = "ff",
                Email             = "*****@*****.**",
                nbAvertissement   = 3,
                MotDePasse        = "123456",
                ConfirmMotDePasse = "123456"
            };
            Etudiant Etud1 = new Etudiant()
            {
                nomComplet = new NomComplet()
                {
                    Nom = "Ramzi", Prenom = "Louati"
                },
                Filiere           = "GL",
                Image             = "ff",
                Email             = "*****@*****.**",
                nbAvertissement   = 3,
                MotDePasse        = "123456",
                ConfirmMotDePasse = "123456"
            };
            IEtudiantService ES = new EtudiantService();

            ES.Add(Etud);
            ES.Add(Etud1);
            ES.Commit();
            Console.WriteLine("---------------------------Affichage des Etudiants-------------------------------------");
            foreach (var item in ES.GetAll())
            {
                Console.WriteLine("les etudiants:" + item.nomComplet.Nom + " " + item.nomComplet.Prenom + " " + item.Filiere);
            }
            Console.WriteLine("---------------------------Affichage de la liste trié de prof  selon leur Code---------");
            ps.ListProfTrie();
            Console.WriteLine("---------------------------Affichage des deux premiers Profs---------------------------");
            ps.deuxPremiersProf();
            Console.WriteLine("---------------------------Nombre Total des etudiants--------------------------------- ");
            Console.WriteLine(ES.nbrtotdesetudiants());
            Console.WriteLine("---------------------------Liste des livres disponibles---------------------------------");
            LS.LISTElivreDispo();
            Console.WriteLine("--------------------------Autorisation Emprunt-----------------------------------------");
            Emprunt E = new Emprunt()
            {
                DocumentCode = 1, AdherantCode = 1, Date = new DateTime(2018, 12, 12)
            };
            Emprunt E1 = new Emprunt()
            {
                AdherantCode = 1, DocumentCode = 3, Date = new DateTime(2018, 01, 01)
            };
            Emprunt E2 = new Emprunt()
            {
                AdherantCode = 1, DocumentCode = 4, Date = new DateTime(2018, 02, 12)
            };
            Emprunt E3 = new Emprunt()
            {
                AdherantCode = 1, DocumentCode = 6, Date = new DateTime(2018, 04, 14)
            };
            EmpruntService Em = new EmpruntService();


            //Em.AutorisationEmprunt(E);
            //Em.AutorisationEmprunt(E1);
            // Em.AutorisationEmprunt(E2);
            Em.AutorisationEmprunt(E3);



            Console.WriteLine("----------------------nouveaux Enseignants---------------------------------------------");
            ps.NouvEnseignants();
            Console.ReadKey();
        }
예제 #6
0
        public Livre ObtenirLivre(int id)
        {
            Livre livreTrouve = bdd.Livres.FirstOrDefault(livre => livre.Id == id);

            return(livreTrouve);
        }
예제 #7
0
 public static void removeLivre(Livre livre)
 {
     DalManager.Instance.Livres.Remove(livre);
 }
예제 #8
0
        public JsonResult VerifTitreLivre(Livre livre)
        {
            bool resultat = !Livres.LivreExiste(livre.Titre);

            return(Json(resultat, JsonRequestBehavior.AllowGet));
        }
 public void ajouterLivre(Livre livre)
 {
     this.livres.Add(livre.ISBN, livre);
 }
예제 #10
0
        public IHttpActionResult ModifLivre([FromBody] JObject dd)
        {
            string idd    = dd.GetValue("id").ToString();
            string titre0 = dd.GetValue("titre").ToString();
            string descr0 = dd.GetValue("descr").ToString();
            //exemple: string date = "2000";
            int    dt       = Convert.ToInt32(dd.GetValue("date").ToString());
            string idauteur = dd.GetValue("idaut").ToString();
            string rv       = dd.GetValue("rowVersion").ToString();

            int id = Convert.ToInt32(idd);

            byte[] rowVersion = Encoding.ASCII.GetBytes(rv);


            if (id <= 0 || id >= 100000 || MotValide(titre0) == false || MotValide(descr0) == false ||
                MotValide(idauteur) == false || dt > DateTime.Now.Year)
            {
                return(BadRequest());
            }

            Livre livreedit = db.Livres.Find(idd);

            if (livreedit == null)
            {
                Debug.WriteLine("  Unable to save changes. The department was deleted by another user.");
                return(BadRequest());
            }

            livreedit.anneeCrea = dt;
            livreedit.idAut     = idauteur;
            livreedit.titre     = titre0;
            livreedit.descr     = descr0;

            try
            {
                db.Entry(livreedit).OriginalValues["RowVersion"] = rowVersion;
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                var entry         = ex.Entries.Single();
                var clientValues  = (Livre)entry.Entity;
                var databaseEntry = entry.GetDatabaseValues();
                if (databaseEntry == null)
                {
                    // ModelState.AddModelError(string.Empty,
                    //  "Unable to save changes. The department was deleted by another user.");
                    Debug.WriteLine("Unable to save changes. The department was deleted by another user.");
                }
                else
                {
                    var databaseValues = (Livre)databaseEntry.ToObject();

                    if (databaseValues.titre != clientValues.titre)
                    {
                        Debug.WriteLine(" titre, Current value: "
                                        + databaseValues.titre);
                    }
                    if (databaseValues.Auteur != clientValues.Auteur)
                    {
                        Debug.WriteLine("Auteur, Current value: "
                                        + databaseValues.idAut);
                    }
                    if (databaseValues.descr != clientValues.descr)
                    {
                        Debug.WriteLine("description, Current value: "
                                        + databaseValues.descr);
                    }
                    Debug.WriteLine("The record attempted to edit "
                                    + "was modified by another user after  got the original value. The "
                                    + "edit operation was canceled and the current values in the database "
                                    + "have been displayed");
                    livreedit.RowVersion = databaseValues.RowVersion;
                }
            }



            return(Ok());
        }
예제 #11
0
        private static void Main()
        {
            Action <string> display          = Console.WriteLine;
            Action <string> displayOnOneLine = Console.Write;

            display("Demo to use the useful functions DLL");
            int[] list   = { 1, 2, 3, 1 };
            bool  result = StringFunc.HasDuplicate(list);

            display("The array: {1, 2, 3, 1 } has duplicate: " + result);
            display(string.Empty);
            displayOnOneLine("Factorial 3 with lowerBound 2 is ");
            displayOnOneLine(MathFunc.Factorial(3, 2).ToString());
            display(string.Empty);
            displayOnOneLine("IsNumeric of '4' ");
            displayOnOneLine(StringFunc.IsNumeric("4").ToString());

            char[] tmpNull = null;
            // ReSharper disable once ExpressionIsAlwaysNull
            string rdnString = StringFunc.GenerateRandomString(tmpNull);

            display(string.Empty);
            display("Generation of a random string: " + rdnString);
            display(string.Empty);
            display("Manifest of the DLL: " + StringFunc.Manifest());
            display(string.Empty);
            display("Generation of a 10 random filename strings: ");
            for (int i = 0; i < 10; i++)
            {
                rdnString = StringFunc.GenerateRandomString(new[] { ' ' }, true, enumRnd.UpperLowerDigitSpecial, 8, true);
                display("Random filename: " + rdnString);
            }

            string test = Path.GetRandomFileName();

            display(string.Empty);
            display("Generation of a 10 Path.GetRandomFileName: ");
            for (int i = 0; i < 10; i++)
            {
                display("Random filename: " + Path.GetRandomFileName());
            }

            display("Listing all drives:");
            List <DriveInfo> allDir = FileFunc.GetAllDrives(new[] { DriveType.CDRom, DriveType.Network,
                                                                    DriveType.Removable });

            foreach (var dirName in allDir)
            {
                display(dirName.ToString());
            }

            display("displaying all directories:");
            var allfilesAndFolders = FileFunc.GetAllDirectories(@"C:\");
            var count = 0;

            foreach (var item in allfilesAndFolders)
            {
                display(item);
                count++;
            }

            display(count + " directories were found");
            display("");
            display("Punctuation characters:");
            display("Period: " + Punctuation.Period);
            display("Backslash: " + Punctuation.Backslash);
            display("Colon: " + Punctuation.Colon);

            Livre dune = new Livre
            {
                Auteur = "Frank Herbert",
                Prix   = 20.00M,
                Titre  = "Les enfants de Dune"
            };

            // search for twin primes
            display("Searching for twin primes:");
            foreach (int twin in FunctionsPrimes.GetTwinPrimeBefore(500))
            {
                Console.Write($"{twin} ");
            }

            Stopwatch chrono2 = new Stopwatch();

            chrono2.Start();
            var allTwinPrimes = FunctionsPrimes.GetTwinPrimeBefore(int.MaxValue - 2);

            chrono2.Stop();
            TimeSpan ts2          = chrono2.Elapsed;
            string   elapsedTime2 = string.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                  ts2.Hours, ts2.Minutes, ts2.Seconds,
                                                  ts2.Milliseconds / 10);

            try
            {
                using (StreamWriter sw2 = new StreamWriter("twinPrimes.txt"))
                {
                    sw2.WriteLine(string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts2.Hours, ts2.Minutes, ts2.Seconds, ts2.Milliseconds / 10));
                    sw2.WriteLine("RunTime with chrono: " + elapsedTime2);
                    foreach (int twin in allTwinPrimes)
                    {
                        sw2.WriteLine(twin);
                    }
                }
            }
            catch (Exception)
            {
                display("There were an error while trying to write to a file all twin primes before int.max");
            }

            // calculating the time necessary to go through all numbers until int.max about billions
            var       startTime = DateTime.Now;
            Stopwatch chrono    = new Stopwatch();

            chrono.Start();
            for (int i = 0; i < int.MaxValue; i++)
            {
            }

            var endTime = DateTime.Now;

            chrono.Stop();
            TimeSpan ts          = chrono.Elapsed;
            string   elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                 ts.Hours, ts.Minutes, ts.Seconds,
                                                 ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
            using (StreamWriter sw = new StreamWriter("timeToIntMax.txt"))
            {
                sw.WriteLine($"start time is {startTime}");
                sw.WriteLine($"End time is {endTime}");
                sw.WriteLine(string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10));
                sw.WriteLine("RunTime with chrono: " + elapsedTime);
            }

            //for (int i = 0; i < FunctionsPrimes.GetTwinPrimeBefore(500).Count; i +=2)
            //{
            //  Console.Write($"{twin} ");
            //}

            /* twin primes
             * 2-3
             * 11-13
             * 17-19
             * 41-43
             * 71-73
             * 101-103
             * 107-109
             * 197-199
             * 227-229
             * 281-283
             * 311-313
             * 431-433
             * 461-463
             * */

            display("");
            //display("primes:");
            //for (int i = 3; i < 500; i = i + 2)
            //{
            //  if (FunctionsMath.IsPrime(i))
            //  {
            //    Console.Write($"{i} ");
            //  }
            //}


            display("");
            display("Press any key to exit:");
            Console.ReadKey();
        }
예제 #12
0
        static void Main(string[] args)
        {
            InitialiserDatas();

            System.Console.WriteLine("Module03_TP01 Les auteurs");
            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            System.Console.WriteLine("\nLes prénoms des auteurs ayant un nom de famille commençant par 'G'\n");

            IEnumerable <Auteur> prenomAuteurG = ListeAuteurs.Where(a => a.Nom[0] == 'G');

            foreach (Auteur auteur in prenomAuteurG)
            {
                Console.WriteLine(auteur.Prenom);
            }

            //System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            //System.Console.WriteLine("\nl'auteur ayant écrit le plus de livres\n");

            //Auteur auteurPlusLivres = ListeAuteurs.OrderByDescending(a => ListeLivres.Count(l => l.Auteur == a)).FirstOrDefault();

            //Console.WriteLine($"{auteurPlusLivres.Nom} {auteurPlusLivres.Prenom}");

            //System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            //System.Console.WriteLine("\nafficher le nombre moyen de pages par auteur\n");

            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            System.Console.WriteLine("\nLe titre du livre avec le plus de pages\n");

            Livre livrePlusPages = ListeLivres.OrderByDescending(l => l.NbPages).First();

            System.Console.WriteLine(livrePlusPages.Titre);

            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            System.Console.WriteLine("\nLa moyenne des factures\n");

            var moyenneFactures = ListeAuteurs.Sum(a => a.Factures.Sum(f => f.Montant)) / ListeAuteurs.SelectMany(a => a.Factures).Count();

            System.Console.WriteLine(moyenneFactures);

            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            System.Console.WriteLine("\nla liste des auteurs et leurs livres\n");

            foreach (Auteur a in ListeAuteurs)
            {
                Console.WriteLine($"\n{a.Nom} {a.Prenom} à écrit :");
                foreach (Livre l in ListeLivres)
                {
                    if (a.Nom == l.Auteur.Nom)
                    {
                        Console.WriteLine($"-{l.Titre}");
                    }
                }
            }

            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            System.Console.WriteLine("\nla liste des livres triés par ordre alphabétique\n");

            IEnumerable <Livre> listeLivreTrie = ListeLivres.OrderBy(a => a.Titre);

            foreach (Livre l in listeLivreTrie)
            {
                Console.WriteLine($"-{l.Titre}");
            }

            System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            System.Console.WriteLine("\nla liste des livres dont le nombre de pages est supérieur à la moyenne\n");

            IEnumerable <Livre> listeLivreSupNbPage = ListeLivres.Where(l => (l.NbPages) > (ListeLivres.Sum(li => li.NbPages) / ListeLivres.Count()));

            foreach (Livre l in listeLivreSupNbPage)
            {
                Console.WriteLine($"-{l.Titre}");
            }

            //System.Console.WriteLine("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
            //System.Console.WriteLine("\nl'auteur ayant écrit le moins de livres\n");

            //Auteur auteurMoinsLivres = ListeAuteurs.OrderBy(a => ListeLivres.Count(l => l.Auteur == a)).FirstOrDefault();

            //Console.WriteLine($"{auteurMoinsLivres.Nom} {auteurMoinsLivres.Prenom}");

            Console.ReadKey();
        }
예제 #13
0
 public FHistorique(Livre unLivre)
 {
     InitializeComponent();
     unLivre.ChangementPrix += UnLivre_ChangementPrix;
 }
예제 #14
0
 public Livre Add(Livre livre)
 {
     context.Livre.Add(livre);
     context.SaveChanges();
     return(livre);
 }
예제 #15
0
 public FormulaireModificationModel(Livre livreEnCoursDeModification)
 {
     this.LivreEnCoursDeModification = livreEnCoursDeModification;
 }
예제 #16
0
 public void Add(Livre livre) => _repository.Create(livre);
예제 #17
0
 public IActionResult Modify([FromBody] Livre Livre)
 {
     _model.Update(Livre);
     return(Ok(_model));
 }
예제 #18
0
 public void Delete(Livre livre) => _repository.Delete(livre);
예제 #19
0
        public bool LivreExiste(string titre)
        {
            Livre livreTrouve = bdd.Livres.FirstOrDefault(livre => livre.Titre == titre);

            return(livreTrouve != null);
        }
예제 #20
0
 public void Update(Livre livre) => _repository.Update(livre);
예제 #21
0
 public static void addLivre(Livre livre)
 {
     DalManager.Instance.Livres.Add(livre);
 }
예제 #22
0
        static void Main(string[] args)
        {
            InitialiserDatas();
            Console.WriteLine(" - Liste des auteurs dont le nom commence par G :");
            IEnumerable <Auteur> listAuteurStartG = ListeAuteurs.Where(a => a.Nom.StartsWith("G"));

            foreach (Auteur auteur in listAuteurStartG)
            {
                Console.WriteLine(auteur.Nom);
            }


            Console.WriteLine("");
            Console.WriteLine(" - Auteur ayant le plus de livres :");
            Auteur auteurMoreBook = ListeLivres.GroupBy(l => l.Auteur).OrderByDescending(a => a.Count()).First().Key;

            Console.WriteLine(auteurMoreBook.Nom + " " + auteurMoreBook.Prenom);


            Console.WriteLine("");
            Console.WriteLine(" - Nombre moyen de pages par livre par auteur :");
            foreach (Auteur auteur in ListeAuteurs)
            {
                IEnumerable <Livre> listLIvreOfAUthor = ListeLivres.Where(l => l.Auteur == auteur);

                double nbPagesByAuthor;
                if (listLIvreOfAUthor.Count() > 0)
                {
                    nbPagesByAuthor = listLIvreOfAUthor.Average(l => l.NbPages);
                }
                else
                {
                    nbPagesByAuthor = 0;
                }
                Console.WriteLine(auteur.Nom + " " + auteur.Prenom + " nombre de pages moyens : " + nbPagesByAuthor);
            }


            Console.WriteLine("");
            Console.WriteLine(" - Livre avec le plus de page :");
            Livre livreMaxPage = ListeLivres.OrderByDescending(l => l.NbPages).First();

            Console.WriteLine(livreMaxPage.Titre);


            Console.WriteLine("");
            Console.WriteLine(" - Combien ont gagné les auteurs en moyennes :");
            decimal avg = ListeAuteurs.Average(a => a.Factures.Sum(f => f.Montant));

            Console.WriteLine(avg);


            Console.WriteLine("");
            Console.WriteLine(" - La listes des auteurs et leur livres :");
            IEnumerable bookByAuteur = ListeLivres.GroupBy(l => l.Auteur);

            foreach (Auteur auteur in ListeAuteurs)
            {
                Console.WriteLine(auteur.Nom);
                IEnumerable <Livre> livresOfAuthor = ListeLivres.Where(l => l.Auteur == auteur);
                printListLivres(livresOfAuthor);
            }


            Console.WriteLine("");
            Console.WriteLine(" - Liste des livres par ordre alphabétique :");
            IEnumerable <Livre> livreAlpha = ListeLivres.OrderBy(l => l.Titre).Distinct();

            printListLivres(livreAlpha);


            Console.WriteLine("");
            Console.WriteLine(" - Liste des livres dont le  nombre de page est supérieur à la moyenne :");
            double moyenne = ListeLivres.Average(l => l.NbPages);
            IEnumerable <Livre> livreMoreMoyenne = ListeLivres.Where(l => l.NbPages > moyenne);

            printListLivres(livreMoreMoyenne);


            Console.WriteLine("");
            Console.WriteLine(" - Auteur ayant écrit le moins de livre :");
            Auteur auteurLessBook = ListeAuteurs.OrderBy(a => ListeLivres.Where(l => l.Auteur == a).Count()).First();

            Console.WriteLine(auteurLessBook.Nom + " " + auteurLessBook.Prenom);

            Console.ReadKey();
        }
 public bool Equals(Livre other)
 {
     return(Titre.Equals(other.Titre) && Auteurs.Equals(other.Auteurs) && Editeur.Equals(other.Editeur) && Genres.Equals(other.Genres) && DateAjout.Equals(other.DateAjout));
 }
예제 #24
0
 public void InsertLivre(Livre livre)
 {
     context.Livre.Add(livre);
 }
예제 #25
0
 //crud
 public void addarticle(Livre art)
 {
     db.Livre.Add(art);
     db.SaveChanges();
 }
예제 #26
0
 public void UpdateLivre(Livre livre)
 {
     context.Entry(livre).State = EntityState.Modified;
 }
예제 #27
0
        static void Main(string[] args)
        {
            //********Sérialisation d'un object **********************
            Livre li01 = new Livre()
            {
                Titre = "Molière"
            };
            Livre li02 = new Livre()
            {
                Titre = "Scalpin"
            };
            Livre li03 = new Livre()
            {
                Titre = "Mortedo"
            };
            Livre li04 = new Livre()
            {
                Titre = "Machin"
            };
            Livre li05 = new Livre()
            {
                Titre = "Médor"
            };
            List <Livre> livres = new List <Livre>();

            livres.Add(li01);
            livres.Add(li02);
            livres.Add(li03);
            livres.Add(li04);
            livres.Add(li05);

            Bibliotheque bibliothequeAdacente = new Bibliotheque();
            Bibliotheque bibliotheque         = new Bibliotheque()
            {
                Livres = livres, BibliothequeAdjacente = bibliothequeAdacente, Theme = "Blanc"
            };

            Console.WriteLine("Test de sérialisation");

            XmlSerializer serializer = new XmlSerializer(typeof(Bibliotheque));

            //Un stream writer permet d'ouvrir un fichier sur le disque
            //source\repos\serialisationXML\serialisationXML\bin\Debug

            using (StreamWriter writer = new StreamWriter("Bibliotheque.xml"))
            {
                serializer.Serialize(writer, bibliotheque);
                bibliotheque.WriteLine();
            }

            //********Désérialisation d'un object **********************

            string stringXml =
                "<?xml version='1.0' encoding='utf-16'?>" +
                "<User>" +
                "<ID>1</ID>" +
                "<name>admin</name>" +
                "<passwd>MD5:F78B - 5AFD - FAA4 - 7D5S - 2EDB - 99E4 - A19B - FF67</passwd>" +
                "</User>";

            //XmlDocument xmlDoc = new XmlDocument();
            //xmlDoc.LoadXml(stringXml);
            //Console.WriteLine(xmlDoc.ToString());
            XDocument xdoc = new XDocument();

            xdoc = XDocument.Parse(stringXml);

            Console.WriteLine(xdoc.ToString());

            string rsaString = "<?xml version='1.0' encoding='utf-16'?>" +
                               "<Record contentId='3537257' levelId='287' levelGuid='6f22f885-b890-4c9e-970b-8d9a9bb58dd5' moduleId='469' parentId='0'>" +
                               "<Field id='22682' guid='0bfcbb80-2a02-4d02-8984-5cbf348fb493' type='1'>CNT-3537257</Field>" +
                               "<Field id='22679' guid='ff320dec-379a-4154-83e7-6ef0bbdb606f' type='2'>25</Field>" +
                               "<Field id='22678' guid='0ae11114-ae06-464f-9e08-b1b68aa5f2b0' type='2'>100</Field>" +
                               "<Field id='22681' guid='107ce810-0324-4745-8682-ad420a20395c' type='2'>0</Field>" +
                               "<Field id='22677' guid='d762a559-e32a-45e5-9064-d538c7aacfd0' type='1'>[22679]/[22679]*100</Field>" +
                               "<Field id='22680' guid='3c19fc58-8517-45e2-94d3-865c98124cf5' type='2'/>" +
                               "</Record>";

            XDocument xdocRsa = XDocument.Parse(rsaString);

            Console.WriteLine(xdocRsa.ToString());

            Console.WriteLine("---------Deserialisation User-----------");

            GetMethod getMethod    = new GetMethod();
            string    path         = string.Empty;
            string    xmlInputData = string.Empty;
            //string xmlOutputData = string.Empty;

            User user = getMethod.Deserialize <User>(stringXml);

            Console.WriteLine("user.Name : " + user.Name);
            Console.WriteLine("---------Deserialisation Record-----------");

            string returnRsaString = getRSACtrl();

            Records records = getMethod.Deserialize <Records>(returnRsaString);


            for (int i = 0; i < records.Record.Length; i++)
            {
                Console.WriteLine("record : " + records.Record[i]);
            }

            for (int i = 0; i < records.Field.Length; i++)
            {
                Console.WriteLine("record.Field : " + records.Field[i]);
            }

            Console.WriteLine("record n° 1 : " + records.Record[0]);


            Console.WriteLine("---------End-----------");
            Console.ReadKey();
        }
예제 #28
0
 public IActionResult Add([FromBody] Livre Livre)
 {
     _model.Add(Livre);
     return(Ok(_model));
 }
예제 #29
0
        private BddBouchon()
        {
            // Initialisation des auteurs
            Auteur auteur1 = new Auteur {
                Id = 1, Nom = "Stephen King"
            };
            Auteur auteur2 = new Auteur {
                Id = 2, Nom = "Victor Hugo"
            };
            Auteur auteur3 = new Auteur {
                Id = 3, Nom = "Lewis Carroll"
            };
            Auteur auteur4 = new Auteur {
                Id = 4, Nom = "Isaac Asimov"
            };

            Auteurs = new List <Auteur> {
                auteur1, auteur2, auteur3, auteur4
            };
            // Initialisation des livres
            Livre livre1 = new Livre {
                Id = 1, Titre = "Shinning", DateParution = new DateTime(1977, 1, 28), Auteur = auteur1
            };
            Livre livre2 = new Livre {
                Id = 2, Titre = "Docteur Sleep", DateParution = new DateTime(2013, 9, 24), Auteur = auteur1
            };
            Livre livre3 = new Livre {
                Id = 3, Titre = "Misery", DateParution = new DateTime(1987, 6, 8), Auteur = auteur1
            };
            Livre livre4 = new Livre {
                Id = 4, Titre = "Notre-Dame de Paris", DateParution = new DateTime(1831, 3, 1), Auteur = auteur2
            };
            Livre livre5 = new Livre {
                Id = 5, Titre = "Les Aventures d’Alice au pays des merveilles", DateParution = new DateTime(1865, 7, 4), Auteur = auteur3
            };

            Livres = new List <Livre> {
                livre1, livre2, livre3, livre4, livre5
            };
            // Initialisation des clients
            Client client1 = new Client {
                Email = "*****@*****.**", Nom = "Franck Ribery"
            };
            Client client2 = new Client {
                Email = "*****@*****.**", Nom = "Steevy Boulay"
            };

            Clients = new List <Client> {
                client1, client2
            };
            // Initialisation des emprunts
            Emprunt emprunt1 = new Emprunt {
                Id = 1, Client = client1, Livre = livre1, DateEmprunt = DateTime.Now
            };
            Emprunt emprunt2 = new Emprunt {
                Id = 2, Client = client1, Livre = livre2, DateEmprunt = DateTime.Now
            };
            Emprunt emprunt3 = new Emprunt {
                Id = 3, Client = client2, Livre = livre3, DateEmprunt = DateTime.Now
            };

            Emprunts = new List <Emprunt> {
                emprunt1, emprunt2, emprunt3
            };
        }
예제 #30
0
 public IActionResult Remove([FromBody] Livre Livre)
 {
     _model.Delete(Livre);
     return(Ok(_model));
 }
        static void Main(string[] args)
        {
            WriteLine("Test de la classe Manager\n");

            StubBibliothèqueDataManager bibliothèqueDataManager = new StubBibliothèqueDataManager();

            bibliothèqueDataManager.ToutRetirer();

            bibliothèqueDataManager.ObtenirPrincipale().AjouterOeuvre(new Film("unFilmListePrincipale", "CheminImageFilmListePrincipale",
                                                                               new DateTime(2016, 01, 25), "unRéalisateur", "unStudio", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                                               "Ceci est un synopsis - Film - ListePrincipale",
                                                                               "Ceci est un commentaire personnel - Film - ListePrincipale"));

            bibliothèqueDataManager.ObtenirPrincipale().AjouterOeuvre(new Livre("unLivreListePrincipale", "CheminImageLivreListePrincipale",
                                                                                new DateTime(1998, 02, 23), "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                                                "Ceci est un synopsis - Livre - ListePrincipale",
                                                                                "Ceci est un commentaire personnel - Livre - ListePrincipale"));

            bibliothèqueDataManager.Ajouter(new Bibliothèque("laBibliothèque1", "CheminImageBiblio1", new ObservableCollection <Oeuvre>()));

            bibliothèqueDataManager.AjouterOeuvre(new Autre("unAutreBibliothèque1", "CheminImageAutreBibliothèque1",
                                                            DateTime.Today, "unCréateur", new ObservableDictionary <StringVérifié, StringVérifié>(), "Ceci est un synopsis - Autre - Bibliothèque1",
                                                            "Ceci est un commentaire personnel - Autre - Bibliothèque1"), bibliothèqueDataManager.ObtenirParNom("laBibliothèque1"));

            bibliothèqueDataManager.AjouterOeuvre(new Film("unFilmBibliothèque1", "CheminImageFilmBibliothèque1",
                                                           new DateTime(2019, 05, 25), "unRéalisateur", "unStudio", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                           "Ceci est un synopsis - Film - Bibliothèque1",
                                                           "Ceci est un commentaire personnel - Film - Bibliothèque1"), bibliothèqueDataManager.ObtenirParNom("laBibliothèque1"));

            bibliothèqueDataManager.AjouterOeuvre(new Série("uneSérieBibliothèque1", "CheminImageSérieBibliothèque1",
                                                            new DateTime(2001, 06, 05), "unRéalisateur", "unStudio", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                            "Ceci est un synopsis - Série - Bibliothèque1",
                                                            "Ceci est un commentaire personnel - Série - Bibliothèque1"), bibliothèqueDataManager.ObtenirParNom("laBibliothèque1"));

            Manager manager = new Manager(bibliothèqueDataManager);


            Bibliothèque bibliothèque2 = new Bibliothèque("laBibliothèque2", "CheminImageBiblio2", new ObservableCollection <Oeuvre>());

            bibliothèque2.AjouterOeuvre(new Livre("unLivreBibliothèque2", "CheminImageLivreBibliothèque2",
                                                  DateTime.Today, "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                  "Ceci est un synopsis - Livre - Bibliothèque2",
                                                  "Ceci est un commentaire personnel - Livre - Bibliothèque2"));

            bibliothèque2.AjouterOeuvre(new Animé("unAniméBibliothèque2", "CheminImageAniméBibliothèque2",
                                                  new DateTime(2015, 05, 01), "unAuteur", "unStudio", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                  "Ceci est un synopsis - Animé - Bibliothèque2",
                                                  "Ceci est un commentaire personnel - Animé - Bibliothèque2"));

            bibliothèque2.AjouterOeuvre(new Scan("unScanBibliothèque2", "CheminImageScanBibliothèque2",
                                                 DateTime.Today, "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                 "Ceci est un synopsis - Scan - Bibliothèque2",
                                                 "Ceci est un commentaire personnel - Scan - Bibliothèque2"));


            manager.AjouterOeuvre(new Livre("unLivreManager", "CheminImageLivreManager",
                                            new DateTime(1998, 02, 23), "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                            "Ceci est un synopsis - Livre - Manager",
                                            "Ceci est un commentaire personnel - Livre - Manager"));

            manager.AjouterBibliothèque(bibliothèque2);

            WriteLine("Regardons les informations du manager");
            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();
            Test_Du_Manager(manager, false);

            Clear();
            WriteLine("Test de la classe Manager\n");
            WriteLine("Réinitialisons le manager, et réaffichons ses informations");
            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();
            manager.RéinitialiserManager();

            Test_Du_Manager(manager, true);

            Clear();
            WriteLine("Test de la classe Manager\n");

            WriteLine("On remet les deux bibliothèques et on suprrime la première via son nom, et la seconde via son Objet :");
            WriteLine($"Ajout de la première : {manager.AjouterBibliothèque(new Bibliothèque("laBibliothèque1", "CheminImageBiblio1", new ObservableCollection<Oeuvre>()))}");
            WriteLine($"Ajout de la seconde : {manager.AjouterBibliothèque(bibliothèque2)}");
            WriteLine($"Suppression de la première : {manager.RetirerBibliothèque("laBibliothèque1")}");
            WriteLine($"Suppression de la seconde : {manager.RetirerBibliothèque(bibliothèque2)}");
            manager.RetirerOeuvre(bibliothèque2[0].Nom); //Car bibliothèque2 contient 3 oeuvres non supprimées de la liste principale
            manager.RetirerOeuvre(bibliothèque2[1].Nom); //Car bibliothèque2 contient 3 oeuvres non supprimées de la liste principale
            manager.RetirerOeuvre(bibliothèque2[2].Nom); //Car bibliothèque2 contient 3 oeuvres non supprimées de la liste principale

            Livre livre = new Livre("unLivreManager", "CheminImageLivreManager",
                                    new DateTime(1998, 02, 23), "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                    "Ceci est un synopsis - Livre - Manager",
                                    "Ceci est un commentaire personnel - Livre - Manager");
            Film film = new Film("unFilmManager", "CheminImageFilmManager",
                                 new DateTime(1998, 02, 23), "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                 "Ceci est un synopsis - Film - Manager",
                                 "Ceci est un commentaire personnel - Film - Manager");

            WriteLine("\nOn remet deux oeuvres dans le manager et on suprrime la première via son nom, et la seconde via son Objet :");
            WriteLine($"Ajout de la première : {manager.AjouterOeuvre(livre)}");
            WriteLine($"Ajout de la seconde : {manager.AjouterOeuvre(film)}");
            WriteLine($"Suppression de la première : {manager.RetirerOeuvre("unLivreManager")}");
            WriteLine($"Suppression de la seconde : {manager.RetirerOeuvre(film)}");

            WriteLine("\nVérifions : ");

            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();

            Test_Du_Manager(manager, true);

            manager.RéinitialiserManager();
            WriteLine($"On réinitialise le manager puis on ajoute une oeuvre : {manager.AjouterOeuvre(livre)}");
            WriteLine("\nEt on l'affiche : \n");
            WriteLine(manager.ListePrincipale[0]);

            WriteLine("\n\nTappez sur entrez pour continuer et voir ses oeuvres");
            ReadLine();
            Clear();

            bool modif = manager.ModifierOeuvre("unLivreManager", "unLivreManagerModifié", "CheminImageLivreManagerModifié",
                                                DateTime.Today, null, "unÉditeurModifié",
                                                new ObservableDictionary <StringVérifié, StringVérifié>()
            {
                { new StringVérifié("UnNomInfoModifié"), new StringVérifié("UneInfoModifiée") },
                { new StringVérifié("UnAutreNomInfoModifiée"), new StringVérifié("UneAutreInfoModifiée") }
            },
                                                "Ceci est un synopsis modifié - Livre - Manager",
                                                "Ceci est un commentaire personnel modifié - Livre - Manager");

            WriteLine($"On la modifie (sauf l'auteur) : {modif}");
            WriteLine("\nEt on l'affiche : \n");
            WriteLine(manager.ListePrincipale[0]);

            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();

            Bibliothèque uneBibliothèque = new Bibliothèque("uneBibliothèque", "CheminImageuneBiblio", new ObservableCollection <Oeuvre>());

            uneBibliothèque.AjouterOeuvre(new Autre("unAutreUneBibliothèque", "CheminImageAutreUneBibliothèque",
                                                    DateTime.Today, "unCréateur", new ObservableDictionary <StringVérifié, StringVérifié>(), "Ceci est un synopsis - Autre - UneBibliothèque",
                                                    "Ceci est un commentaire personnel - Autre - UneBibliothèque"));

            uneBibliothèque.AjouterOeuvre(new Film("unFilmUneBibliothèque", "CheminImageFilmUneBibliothèque",
                                                   new DateTime(2019, 05, 25), "unRéalisateur", "unStudio", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                   "Ceci est un synopsis - Film - UneBibliothèque",
                                                   "Ceci est un commentaire personnel - Film - UneBibliothèque"));

            uneBibliothèque.AjouterOeuvre(new Série("uneSérieUneBibliothèque", "CheminImageSérieUneBibliothèque",
                                                    new DateTime(2001, 06, 05), "unRéalisateur", "unStudio", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                                    "Ceci est un synopsis - Série - UneBibliothèque",
                                                    "Ceci est un commentaire personnel - Série - UneBibliothèque"));

            Clear();
            WriteLine("Test de la classe Manager\n");

            manager.RéinitialiserManager();
            WriteLine($"On réinitialise le manager puis on ajoute une bibliothèque : {manager.AjouterBibliothèque(uneBibliothèque)}");
            WriteLine("Et on l'affiche via ObtenirBibliothèque : ");
            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();

            Test_D_Une_Bibliothèque(manager.ObtenirBibliothèque("uneBibliothèque"));

            WriteLine("Test de la classe Manager\n");
            WriteLine("\nOn la modifie (sauf le chemin de l'image) et la réaffiche (via l'indexeur avec le nom) :");
            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();
            Clear();

            ObservableCollection <Oeuvre> desOeuvres = new ObservableCollection <Oeuvre>();

            desOeuvres.Add(new Livre("unLivreBiblioModifiée", "CheminImageLivreBiblioModifiée",
                                     DateTime.Today, "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                     "Ceci est un synopsis - Livre - BiblioModifiée",
                                     "Ceci est un commentaire personnel - Livre - BiblioModifiée"));
            desOeuvres.Add(new Animé("unAniméBiblioModifiée", "CheminImageAniméBiblioModifiée",
                                     new DateTime(2015, 05, 01), "unAuteur", "unStudio", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                     "Ceci est un synopsis - Animé - BiblioModifiée",
                                     "Ceci est un commentaire personnel - Animé - BiblioModifiée"));
            desOeuvres.Add(new Scan("unScanBiblioModifiée", "CheminImageScanBiblioModifiée",
                                    DateTime.Today, "unAuteur", "unÉditeur", new ObservableDictionary <StringVérifié, StringVérifié>(),
                                    "Ceci est un synopsis - Scan - BiblioModifiée",
                                    "Ceci est un commentaire personnel - Scan - BiblioModifiée"));

            manager.ModifierBibliothèque("uneBibliothèque", "uneBibliothèqueModifiée", null, desOeuvres);

            Test_D_Une_Bibliothèque(manager["uneBibliothèqueModifiée"]);

            WriteLine("On remarque que la Bibliothèque a été modifiée");
            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();
            Clear();


            WriteLine("Test de la classe Manager\n");

            WriteLine("Ajoutons maintenant les bibliothèques 1 et 2 comme précédemment");
            manager.AjouterBibliothèque(new Bibliothèque("laBibliothèque1", "CheminImageBiblio1", new ObservableCollection <Oeuvre>()));
            manager.AjouterBibliothèque(bibliothèque2);
            WriteLine($"Il devrait donc y avoir 3 bibliothèques, comptons : {manager.NombreBibliothèque()}");

            WriteLine("\nCherchons les bibliothèques avec \'1\' dans le nom : ");
            foreach (Bibliothèque bibliothèque in manager.RechercherBibliothèque("1"))
            {
                WriteLine($"Trouvée : {bibliothèque.Nom}");
            }
            WriteLine("\nCherchons les bibliothèques avec \'biblio\' dans le nom : ");
            foreach (Bibliothèque bibliothèque in manager.RechercherBibliothèque("biblio"))
            {
                WriteLine($"Trouvée : {bibliothèque.Nom}");
            }

            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();
            Clear();

            WriteLine("Test de la classe Manager\n");

            WriteLine("Enfin on test l'indexeur du numéro, en affichant le juste le nom des bibliothèques :");


            for (int i = 0; i < manager.NombreBibliothèque(); i++)
            {
                WriteLine(manager[i].Nom);
            }

            WriteLine("\n\nTappez sur entrez pour continuer");
            ReadLine();
            Clear();
        }
예제 #32
0
        //  BOUTON MODIFIER
        private void btnModifier_Click(object sender, EventArgs e)
        {
            if (btnModifier.Text.Equals("Modifier"))
            {
                // modification de couleur du bouton ajouter + le passe en "valider" et afficher annuler
                btnModifier.BackColor = Color.Green;
                btnModifier.Text      = "Valider";
                btnAnnuler.Visible    = true;

                //desactiver les autres boutons
                btnRechercher.Enabled = false;
                btnSupprimer.Enabled  = false;
                btnAjouter.Enabled    = false;
                if (btnexemp.Text.Equals("Livre"))
                {
                    // textbox activer pour l'insertion

                    txtbxtitre.Enabled       = true;
                    txtbxisbn.Enabled        = true;
                    txtbxcouleur.Enabled     = true;
                    txtbxtome.Enabled        = true;
                    cmbbxannee.Enabled       = true;
                    cmbbxmois.Enabled        = true;
                    txtbxformat.Enabled      = true;
                    txtbxpage.Enabled        = true;
                    txtbxcommentaire.Enabled = true;


                    cmbbxauteur.Enabled      = true;
                    cmbbauteurdessin.Enabled = true;
                    cmbbxediteur.Enabled     = true;
                    cmbbxserie.Enabled       = true;


                    // modification des couleur

                    txtbxtitre.BackColor       = Color.White;
                    txtbxisbn.BackColor        = Color.White;
                    txtbxcouleur.BackColor     = Color.White;
                    txtbxtome.BackColor        = Color.White;
                    cmbbxannee.BackColor       = Color.White;
                    cmbbxmois.BackColor        = Color.White;
                    txtbxformat.BackColor      = Color.White;
                    txtbxpage.BackColor        = Color.White;
                    txtbxcommentaire.BackColor = Color.White;


                    cmbbxauteur.BackColor      = Color.White;
                    cmbbauteurdessin.BackColor = Color.White;
                    cmbbxediteur.BackColor     = Color.White;
                    cmbbxserie.BackColor       = Color.White;
                }
                else if (btnexemp.Text.Equals("exemplaire"))
                {
                    // textbox activer pour l'insertion
                    codelivreexmp.Enabled        = true;
                    txtbxreferencerexemp.Enabled = true;
                    rdbtnA.Enabled  = true;
                    rdbtnb.Enabled  = true;
                    rdbtnta.Enabled = true;
                    rdbtntb.Enabled = true;



                    // modification des couleur


                    txtbxreferencerexemp.BackColor = Color.White;

                    codelivreexmp.BackColor = Color.White;
                }
            }
            else if (btnModifier.Text.Equals("Valider"))
            {
                if (btnexemp.Text.Equals("Livre"))
                {
                    erreurtype = true;
                    try
                    {
                        Convert.ToInt32(txtbxtome.Text);
                    }
                    catch
                    {
                        btDialog("Tome est un entier", true);
                        erreurtype = false;
                    }
                    try
                    {
                        Convert.ToInt32(txtbxpage.Text);
                    }
                    catch
                    {
                        btDialog("Page est un entier", true);
                        erreurtype = false;
                    }
                    if (erreurtype == true)
                    {
                        string parutiontotal = cmbbxmois.Text + "/" + cmbbxannee.Text;

                        Livre lelivre = new Livre(Int32.Parse(txtbxcode.Text), txtbxtitre.Text, txtbxisbn.Text, Int32.Parse(txtbxtome.Text), parutiontotal, Int32.Parse(txtbxpage.Text), "", txtbxcouleur.Text, txtbxcommentaire.Text, txtbxformat.Text, 1, 1);
                        unlivre.update_livre(lelivre, cmbbxediteur.Text, cmbbxserie.Text);
                        reset();
                    }
                }
                else if (btnexemp.Text.Equals("exemplaire"))
                {
                    //verifie en l'etat du radiobouton
                    if (rdbtnA.Checked == true)
                    {
                        resultat = rdbtnA.Text;
                    }
                    else if (rdbtnb.Checked == true)
                    {
                        resultat = rdbtnb.Text;
                    }
                    else if (rdbtnta.Checked == true)
                    {
                        resultat = rdbtnta.Text;
                    }
                    else if (rdbtntb.Checked == true)
                    {
                        resultat = rdbtntb.Text;
                    }
                    erreurtype = true;
                    try
                    {
                        Convert.ToInt32(codelivreexmp.Text);
                    }
                    catch
                    {
                        btDialog("Code est un entier", true);
                        erreurtype = false;
                    }
                    if (erreurtype == true)
                    {
                        Exemplaire lexemplaire = new Exemplaire(txtbxreferencerexemp.Text, resultat, Int32.Parse(codelivreexmp.Text));
                        unexemplaire.update_exemplaire(lexemplaire);
                        reset();
                    }
                }

                // repasse le bouton ajouter en "ajouter" + modification couleur + desactive le bouton annuler
                btnModifier.Text      = "Modifier";
                btnModifier.BackColor = Color.SteelBlue;
                btnAnnuler.Visible    = false;

                //reactivation des autres boutons
                btnRechercher.Enabled = true;
                btnSupprimer.Enabled  = true;
                btnAjouter.Enabled    = true;

                // textbox desactiver pour l'insertion
                txtbxtitre.Enabled       = false;
                txtbxisbn.Enabled        = false;
                txtbxcouleur.Enabled     = false;
                txtbxtome.Enabled        = false;
                cmbbxannee.Enabled       = false;
                cmbbxmois.Enabled        = false;
                txtbxformat.Enabled      = false;
                txtbxpage.Enabled        = false;
                txtbxcommentaire.Enabled = false;

                txtbxreferencerexemp.Enabled = false;
                rdbtnA.Enabled           = false;
                rdbtnb.Enabled           = false;
                rdbtnta.Enabled          = false;
                rdbtntb.Enabled          = false;
                codelivreexmp.Enabled    = false;
                cmbbxauteur.Enabled      = false;
                cmbbauteurdessin.Enabled = false;
                cmbbxediteur.Enabled     = false;
                cmbbxserie.Enabled       = false;

                // modification des couleur
                txtbxcode.BackColor        = Color.Silver;
                txtbxtitre.BackColor       = Color.Silver;
                txtbxisbn.BackColor        = Color.Silver;
                txtbxcouleur.BackColor     = Color.Silver;
                txtbxtome.BackColor        = Color.Silver;
                cmbbxannee.BackColor       = Color.Silver;
                cmbbxmois.BackColor        = Color.Silver;
                txtbxformat.BackColor      = Color.Silver;
                txtbxpage.BackColor        = Color.Silver;
                txtbxcommentaire.BackColor = Color.Silver;

                txtbxreferencerexemp.BackColor = Color.Silver;
                codelivreexmp.BackColor        = Color.Silver;
                cmbbxauteur.BackColor          = Color.Silver;
                cmbbauteurdessin.BackColor     = Color.Silver;
                cmbbxediteur.BackColor         = Color.Silver;
                cmbbxserie.BackColor           = Color.Silver;
                txtbxcode.BackColor            = Color.Silver;
            }
        }