Пример #1
0
        /// <summary>
        /// Récupère un lecteur par ses prénoms et noms.
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="AffToFill"></param>
        public static void GetAffiliateByName(string firstName, string lastName, ref Affiliate AffToFill)
        {
            StringBuilder sLog = new StringBuilder();

            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    Affiliate convertedAff = new Affiliate();
                    var       vAff         = dbEntity.GetAffiliateByName(firstName, lastName).FirstOrDefault();

                    convertedAff.CardNum       = vAff.CardNum;
                    convertedAff.CardValidity  = vAff.Validity;
                    convertedAff.MainLibraryId = vAff.MainLibrary_Id;
                    convertedAff.LastName      = vAff.LastName;
                    convertedAff.FirstName     = vAff.FirstName;
                    convertedAff.BirthDate     = vAff.BirthDate;

                    AffToFill = convertedAff;
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #2
0
        public static void GetAllVolumes(ref List <Volume> listToReturn)
        {
            StringBuilder sLog = new StringBuilder();

            listToReturn.Clear();
            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    foreach (var vvolume in dbEntity.vVolumes)
                    {
                        Volume convertedVol = new Volume();

                        convertedVol.Id      = vvolume.Id;
                        convertedVol.Isbn    = vvolume.Isbn;
                        convertedVol.Title   = vvolume.Title;
                        convertedVol.Cover   = vvolume.Cover;
                        convertedVol.Authors = DalAuthor.GetAllAuthorsNames(vvolume.Isbn);

                        listToReturn.Add((convertedVol));
                    }
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Retourne un volume par son ISBN.
        /// </summary>
        /// <param name="VolumeIsbn"></param>
        /// <param name="VolToFill"></param>
        public static void GetVolumeByIsbn(string VolumeIsbn, ref Volume VolToFill)
        {
            StringBuilder sLog = new StringBuilder();

            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    Volume convertedVol = new Volume();
                    var    vvolume      = dbEntity.GetVolumeByIsbn(VolumeIsbn).FirstOrDefault();

                    convertedVol.Id      = vvolume.Id;
                    convertedVol.Isbn    = vvolume.Isbn;
                    convertedVol.Title   = vvolume.Title;
                    convertedVol.Cover   = vvolume.Cover;
                    convertedVol.Authors = DalAuthor.GetAllAuthorsNames(vvolume.Isbn);

                    VolToFill = convertedVol;
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Retourne la liste des volumes souhaités par le lecteur.
        /// </summary>
        /// <param name="cardNum"></param>
        /// <param name="listToReturn"></param>
        public static void GetWishListByCardNum(int cardNum, ref List <WishListItem> listToReturn)
        {
            StringBuilder sLog = new StringBuilder();

            listToReturn.Clear();
            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    foreach (GetWishlist_Result vWish in dbEntity.GetWishlist(cardNum))
                    {
                        WishListItem wishListItem = new WishListItem();

                        wishListItem.Id        = vWish.Id;
                        wishListItem.CardNum   = vWish.CardNum;
                        wishListItem.Volume_Id = vWish.Volume_Id;
                        wishListItem.Isbn      = vWish.Isbn;
                        //  wishListItem.Title = vWish. ;
                        wishListItem.Cover = vWish.Cover;

                        listToReturn.Add((wishListItem));
                    }
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Retourne la liste de toutes les librairies.
        /// </summary>
        /// <param name="listToReturn"></param>
        public static void GetAllLibraries(ref List <Library> listToReturn)
        {
            StringBuilder sLog = new StringBuilder();

            listToReturn.Clear();
            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    foreach (GetLibraries_Result vlib in dbEntity.GetLibraries().ToList())
                    {
                        Library convertedLib = new Library();

                        convertedLib.Id   = vlib.IdLibrary;
                        convertedLib.Code = vlib.CodeIdLibrary;
                        convertedLib.Name = vlib.NameLibrary;

                        listToReturn.Add((convertedLib));
                    }
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Insère un nouvel emprunt.
        /// La date de départ est crée dans la base de données.
        /// Supprime un éventuel wish item correspondant à cet exemplaire.
        /// (Transaction)
        /// </summary>
        /// <param name="CardNum"></param>
        /// <param name="Item_Id"></param>
        /// <param name="Tarif_Id"></param>
        public static void InsertEmprunt(int cardNum, int item_Id, int volume_Id, int tarif_Id)
        {
            StringBuilder sLog = new StringBuilder();

            try
            {
                using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        dbEntity.InsertEmprunt(cardNum, item_Id, tarif_Id);
                        foreach (var wishes in dbEntity.GetWishlist(cardNum).Where(w => w.Volume_Id == volume_Id))
                        {
                            dbEntity.DeleteWishById(wishes.Id);
                            ts.Complete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                int DefaultError = 12; //" Un problème est survenu à l'ajout !"
                throw new EL.CstmError(DefaultError, ex);
            }
        }
Пример #7
0
        public static void GetItemsByVOlume(int volumeId, ref List <Item> listToReturn)
        {
            StringBuilder sLog = new StringBuilder();

            listToReturn.Clear();
            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    foreach (GetItemByVol_Result vItem in dbEntity.GetItemByVol(volumeId)) //vEmpruntDetail
                    {
                        Item itemToReturn = new Item();
                        itemToReturn.Id           = vItem.Id;
                        itemToReturn.LibraryId    = vItem.Library_Id;
                        itemToReturn.VolumeId     = vItem.Volume_Id;
                        itemToReturn.Code         = vItem.Code;
                        itemToReturn.BuyDate      = (DateTime)vItem.BuyDate;
                        itemToReturn.Localisation = vItem.Localisation;

                        listToReturn.Add((itemToReturn));
                    }
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// retourne les tarifs d'une librairie.
        /// </summary>
        /// <param name="libId"></param>
        /// <param name="listToReturn"></param>
        public static void GetTarifByLib(int libId, ref List <Tarif> listToReturn)
        {
            StringBuilder sLog = new StringBuilder();

            listToReturn.Clear();
            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    foreach (GetTarifByLibId_Result _vTarif in dbEntity.GetTarifByLibId(libId))
                    {
                        Tarif _tarif = new Tarif();

                        _tarif.Id           = _vTarif.Id;
                        _tarif.DailyPenalty = _vTarif.DailyPenalty;
                        _tarif.Duration     = _vTarif.Duration;
                        _tarif.Fee          = _vTarif.Fee;
                        _tarif.LibraryId    = _vTarif.Library_Id;
                        _tarif.Name         = _vTarif.Name;
                        _tarif.Year         = _vTarif.Year;

                        listToReturn.Add((_tarif));
                    }
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #9
0
        public static List <Author> GetAllAuthorsNames(string isbn)
        {
            StringBuilder sLog = new StringBuilder();

            List <Author> listToReturn = new List <Author>();

            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    foreach (var author in dbEntity.GetAuthorByVolumeIsbn(isbn).ToList())
                    {
                        Author convertedAuthor = new Author();

                        convertedAuthor.PersId    = author.Pers_Id;
                        convertedAuthor.FirstName = author.FirstName;
                        convertedAuthor.LastName  = author.LastName;

                        listToReturn.Add((convertedAuthor));
                    }
                    return(listToReturn);
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Suppresion d'un volume de la wishlist.
        /// </summary>
        /// <param name="WishId"></param>
        public static void DeleteWishListItem(int WishId)
        {
            StringBuilder sLog = new StringBuilder();

            try
            {
                using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
                {
                    dbEntity.DeleteWishById(WishId);
                }
            }
            catch (Exception ex)
            {
                int DefaultError = 10; //" Un problème est survenu à la modification des données !"
                throw new EL.CstmError(DefaultError, ex);
            }
        }
Пример #11
0
        /// <summary>
        /// Ajout d'une "réservation" dans la wishlist.
        /// </summary>
        /// <param name="cardNum"></param>
        /// <param name="volumeId"></param>
        public static void AddWishListItem(int cardNum, int volumeId)
        {
            StringBuilder sLog = new StringBuilder();

            try
            {
                using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
                {
                    dbEntity.InsertWish(cardNum, volumeId);
                }
            }
            catch (Exception ex)
            {
                int DefaultError = 12; //" Un problème est survenu à l'ajout !"
                throw new EL.CstmError(DefaultError, ex);
            }
        }
Пример #12
0
        /// <summary>
        /// retourne les emprunts du lecteur.
        /// Sous forme de liste d'objets Emprunt.
        /// </summary>
        /// <param name="cardNum"></param>
        /// <param name="listToReturn"></param>
        public static void GetEmpruntsByCardNum(int cardNum, bool SelectClosed, ref List <Emprunt> listToReturn)
        {
            StringBuilder sLog = new StringBuilder();

            listToReturn.Clear();
            using (ExamSGBD2017Entities dbEntity = new ExamSGBD2017Entities())
            {
                try
                {
                    foreach (GetEmpruntByAffiliate_Result vEmprunt in dbEntity.GetEmpruntByAffiliate(cardNum, SelectClosed)) //vEmpruntDetail
                    {
                        Emprunt convertedEmprunt = new Emprunt();

                        convertedEmprunt.Id           = vEmprunt.IdEmprunt;
                        convertedEmprunt.CardNum      = vEmprunt.CardNum;
                        convertedEmprunt.LibraryId    = vEmprunt.Library_Id;
                        convertedEmprunt.LibraryName  = vEmprunt.NameLibrary;
                        convertedEmprunt.VolumeTitle  = vEmprunt.Title;
                        convertedEmprunt.ItemCode     = vEmprunt.Code;
                        convertedEmprunt.ItemId       = vEmprunt.Item_Id;
                        convertedEmprunt.TarifName    = vEmprunt.NameTarif;
                        convertedEmprunt.Fee          = vEmprunt.Fee;
                        convertedEmprunt.DailyPenalty = vEmprunt.DailyPenalty;
                        convertedEmprunt.Duration     = vEmprunt.Duration;
                        convertedEmprunt.StartDate    = vEmprunt.StartDate;
                        convertedEmprunt.ReturnDte    = vEmprunt.ReturnDate ?? DateTime.Now;
                        convertedEmprunt.LastModified = vEmprunt.LastModified ?? DateTime.Now;
                        //   convertedEmprunt.Isbn = vEmprunt.;
                        //   convertedEmprunt.Cover = vEmprunt.;
                        //   convertedEmprunt.Authors = DalAuthor.GetAllAuthorsNames(vEmprunt.);

                        listToReturn.Add((convertedEmprunt));
                    }
                }
                catch (Exception ex)
                {
                    int DefaultError = 7; //"Problème à la récupération des données !"
                    throw new EL.CstmError(DefaultError, ex);
                }
            }
        }