Esempio n. 1
0
        public void EmpruntSucces()
        {
            Pret pret = adherent.Emprunte(exemplaire1);

            Assert.IsTrue(adherent.Prets.Contains(pret));
            Assert.IsFalse(pret.EstTermine());
            Assert.IsFalse(exemplaire1.EstDisponible());
        }
Esempio n. 2
0
        public void TraiterEmprunt(int idAdherent, int idExemplaire)
        {
            using (IUnitOfWork uow = BeginTransaction())
            {
                Adherent adherent = depotAdherents.Read(idAdherent);
                if (adherent == null)
                {
                    throw new Exception("L'adhérent est inconnu.");
                }
                if (adherent.EstQuotaDepasse())
                {
                    throw new Exception("L'adhérent ne peut pas emprunter plus d'exemplaires.");
                }

                Exemplaire exemplaire = depotExemplaires.Read(idExemplaire);
                if (exemplaire == null)
                {
                    throw new Exception("L'exemplaire est inconnu.");
                }
                if (!exemplaire.EstDisponible())
                {
                    throw new Exception("L'exemplaire est en cours de prêt.");
                }

                adherent.Emprunte(exemplaire);

                depotAdherents.Update(adherent);
                depotExemplaires.Update(exemplaire);

                uow.Commit();
            }
        }
Esempio n. 3
0
 private void buttonEmprunter_Click(object sender, EventArgs e)
 {
     // TODO:
     if (adherents.Count > 0 && exemplaires.Count > 0)
     {
         // 1. Recuperer l'identifiant de l'adherent selectionné
         string   selectedTxt = listBoxAdherents.SelectedItem as string;
         Adherent adherent    = adherents
                                .Find(a => a.ToString() == selectedTxt);
         // 2. Recuperer l'identifiant de l'exemplaire selectionné
         selectedTxt = listBoxExemplaires.SelectedItem as string;
         Exemplaire exemplaire = (exemplaires as List <Exemplaire>)
                                 .Find(ex => ex.ToString() == selectedTxt);
         try
         {
             // 3. Execution de l'emprunt
             adherent.Emprunte(exemplaire);
             // 4. Mis à jour de l'IHM
             Actualiser();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Emprunt échoué", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Pas d'adhérent ou d'exemplaire !", "Emprunt échoué", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
        public void TraiterEmprunt(int idAdherent, int idExemplaire)
        {
            using (IUnitOfWork uow = BeginTransaction())
            {
                Adherent   adherent   = depotAdherents.Read(idAdherent);
                Exemplaire exemplaire = depotExemplaires.Read(idExemplaire);

                if (exemplaire == null)
                {
                    throw new Exception("Vous ne pouvez pas emprunter cela !");
                }

                Pret pret = adherent.Emprunte(exemplaire);
                depotAdherents.Update(adherent);
                depotPrets.Create(pret);

                uow.Commit();
            }
        }
Esempio n. 5
0
        public void TraiterEmprunt(int idAdherent, int idExemplaire)
        {
            using (IUnitOfWork uow = BeginTransaction())
            {
                Adherent   adh = depotAdherents.Read(idAdherent);
                Exemplaire ex  = depotExemplaires.Read(idExemplaire);

                if (adh == null)
                {
                    throw new Exception(" Pas d'adherent");
                }
                if (ex == null)
                {
                    throw new Exception(" Pas d'exemplaire");
                }
                adh.Emprunte(ex);
                depotAdherents.Update(adh);

                uow.Commit();
            }
        }