internal void AnnuleDemandeReservation(Action<DemandeAnnulationBO> callbackAction = null)
        {
            if (_demandeReservationSelected == null){
                return;
            }
            var demandeAnnulationIFac = new DemandeAnnulationIFACClient();
            AsyncGuiDemandeAnnulationInsertAnnulation sampleDemandeAnnulationInsertAnnulationDelegate = demandeAnnulationIFac.InsertDemandeAnnulationByClient;
            sampleDemandeAnnulationInsertAnnulationDelegate.BeginInvoke(CGlobalCache.SessionManager.Token, _demandeReservationSelected.ClientId, _demandeReservationSelected.DemandeReservationId, result =>{
                var sampleDemandeAnnulationDelegate = (AsyncGuiDemandeAnnulationInsertAnnulation)((AsyncResult)result).AsyncDelegate;
                var objDemandeAnnulation = sampleDemandeAnnulationDelegate.EndInvoke(result);
                demandeAnnulationIFac.Close();

                if (objDemandeAnnulation == null){
                    MessageBox.Show(Resources.DashboardManager_AnnuleDemandeReservation_La_demande_n_a_pas_ete_executee);
                }

                CGlobalCache.LstNewDemandeReservationByClient.Remove(_demandeReservationSelected);
                _demandeReservationSelected.Valide = 0;
                CGlobalCache.LstOldDemandeReservationByClient.Add(_demandeReservationSelected);
                _demandeReservationSelected = null;

                if (CGlobalCache.LstDemandeReservationSelectAll != null) {
                    CGlobalCache.LstDemandeReservationSelectAll.Remove(_demandeReservationSelected);
                    if (objDemandeAnnulation != null) {
                        CGlobalCache.LstDemandeReservationSelectAll.Add(objDemandeAnnulation.DemandeReservation);
                    }
                }

                if (callbackAction == null){
                    return;
                }

                callbackAction(objDemandeAnnulation);
            }, null);
        }
        internal void SetFicheDeLivre(DemandeReservationBO pDemandeReservation, ReservationBO objReservationResult)
        {
            if (pDemandeReservation == null) {
                return;
            }
            lblTitre.Text = pDemandeReservation.RefLivre.Titre;
            webDescription.DocumentText = pDemandeReservation.RefLivre.Description;
            lblAuteurs.Text = pDemandeReservation.RefLivre.Auteur;
            lblPublication.Text = pDemandeReservation.RefLivre.Published.ToShortDateString();

            Action<String> getImage = (imageUrl) => {
                // Create a web request to the URL for the picture
                var webRequest = WebRequest.Create(imageUrl);
                // Execute the request synchronuously
                var webResponse = (HttpWebResponse)webRequest.GetResponse();

                // Create an image from the stream returned by the web request
                // ReSharper disable AssignNullToNotNullAttribute
                picBook.Image = new Bitmap(webResponse.GetResponseStream());
                // ReSharper restore AssignNullToNotNullAttribute
            };

            lblBibliotheque.Text = objReservationResult != null ? objReservationResult.Emprunt.Livre.Bibliotheque.ToString() : "";

            getImage(pDemandeReservation.RefLivre.ImageUrl);

            Annulation(pDemandeReservation);
        }
 public DemandeReservationBO InsertDemandeReservation(String token, DemandeReservationBO pDemandeReservation)
 {
     if (!Autorization.Validate(token, Autorization.Role.CLIENT)) {
         return null;
     }
     try {
         return DemandeReservationBL.InsertDemandeReservation(pDemandeReservation);
     } catch (Exception ex) {
         throw;
     }
 }
 private void Annulation(DemandeReservationBO pDemandeReservation)
 {
     String newDemandeReservation = "", oldDemandeReservation = "";
     foreach (DemandeReservationBO objDr in CGlobalCache.LstNewDemandeReservationByClient.ToList().FindAll(xx => xx.RefLivreId == pDemandeReservation.RefLivreId && xx.Valide == 1).OrderByDescending(xx => xx.CreatedAt)) {
         newDemandeReservation += ((newDemandeReservation == "") ? "" : "\n") + "En cours: " + objDr.CreatedAt.ToShortDateString();
     }
     foreach (DemandeReservationBO objDr in CGlobalCache.LstOldDemandeReservationByClient.ToList().FindAll(xx => xx.RefLivreId == pDemandeReservation.RefLivreId && xx.Valide == 1).OrderByDescending(xx => xx.CreatedAt)) {
         oldDemandeReservation += ((oldDemandeReservation == "") ? "": "\n" ) + "Passée: " + objDr.CreatedAt.ToShortDateString();
     }
     lblOldReservationStatus.Text = oldDemandeReservation;
     lblNewReservationStatus.Text = newDemandeReservation;
 }
        public static DemandeReservationBO InsertDemandeReservation(DemandeReservationBO pDemandeReservation)
        {
            DemandeReservationBO objDemandeReservation = null;

            try {
                using (var demandeReservationDal = new DemandeReservationDAL(Util.GetConnection())) {
                    var lstDemandeReservation = demandeReservationDal.DemandeReservationDAL_InsertDemandeReservation(pDemandeReservation.ClientId, pDemandeReservation.RefLivreId).ToList();
                    if (lstDemandeReservation.Count() == 1) {
                        objDemandeReservation = lstDemandeReservation[0];
                        objDemandeReservation.RefLivre = pDemandeReservation.RefLivre;
                        objDemandeReservation.Personne = PersonneBL.SelectById(objDemandeReservation.ClientId);
                    }
                }
            } catch (Exception ex) {
                throw;
            }

            return objDemandeReservation;
        }
 internal DemandeAnnulationBO SaveAnnuleReservation(AdministrateurBO pAdministrateurBo, DemandeReservationBO pDemandeReservationBo)
 {
     var demandeAnnulationIFac = new DemandeAnnulationIFACClient();
     //throw new NotImplementedException();
     return demandeAnnulationIFac.InsertDemandeAnnulationByAdmininistrateur(CGlobalCache.SessionManager.Token, pAdministrateurBo.AdministrateurId, pDemandeReservationBo.DemandeReservationId);
 }
        private void LoadFicheLivre(DemandeReservationBO pDemandeReservation)
        {
            CreateFicheLivreReservation();

            var refLivreIFac = new ReservationIFACClient();

            AsyncGuiReservationSelectByDemandeReservationId asyncExecute = refLivreIFac.SelectEnCoursValidByReservationId;
            try {
                asyncExecute.BeginInvoke(CGlobalCache.SessionManager.Token, pDemandeReservation.DemandeReservationId, xx => {
                    var samplePersDelegate = (AsyncGuiReservationSelectByDemandeReservationId)((AsyncResult)xx).AsyncDelegate;
                    var objReservationResult = samplePersDelegate.EndInvoke(xx);
                    if (_ficheDeLivreReservation == null) {
                        refLivreIFac.Close();
                        return;
                    }
                    _ficheDeLivreReservation.SetFicheDeLivre(pDemandeReservation, objReservationResult);
                    refLivreIFac.Close();
                }, null);
            } catch(Exception) {
                refLivreIFac.Close();
                MessageBox.Show(Resources.DashboardManager_loadFicheLivre_Erreur_lors_de_la_recuperation_des_informations_sur_le_livre_demande_);
            }
        }
        private void LivreDemandeReservation_MouseDown(object sender, MouseEventArgs e)
        {
            var listBox = (ListBox)sender;

            listBox.SelectedIndex = listBox.IndexFromPoint(e.Location);
            if (listBox.SelectedIndex == -1) {
                return;
            }

            CleanListBoxSelected(listBox);

            if (e.Button == MouseButtons.Left){
                _demandeReservationSelected = (DemandeReservationBO)listBox.SelectedItem;
                LoadFicheLivre(_demandeReservationSelected);
            }
        }
        private void InsertDemandeReservation(Action<DemandeReservationBO> callbackAction = null)
        {
            var objDemandeReservation = new DemandeReservationBO {Client = CGlobalCache.SessionManager.Personne.Client, RefLivre = _livreSelected.RefLivre};

            var demandeReservationIFacClient = new DemandeReservationIFACClient();
            AsyncGuiDemandeReservationInsert insertGuiSampleDemandeReservationDelegate = demandeReservationIFacClient.InsertDemandeReservation;
            insertGuiSampleDemandeReservationDelegate.BeginInvoke(CGlobalCache.SessionManager.Token, objDemandeReservation, result =>{
                var sampleInsertDemandeReservationDelegate = (AsyncGuiDemandeReservationInsert)((AsyncResult)result).AsyncDelegate;
                var objDemandeReservationResult = sampleInsertDemandeReservationDelegate.EndInvoke(result);

                demandeReservationIFacClient.Close();

                if (objDemandeReservationResult == null){
                    MessageBox.Show(Resources.DashboardManager_totoToolStripMenuItem_Click_Le_livre_n_a_pas_pu_etre_ajoute_dans_votre_liste_de_demande);
                    return;
                }

                //CGlobalCache.AddNewDemandeReservationByClient(objDemandeReservationResult);
                CGlobalCache.LstNewDemandeReservationByClient.Add(objDemandeReservationResult);
                if (CGlobalCache.SessionManager.Personne.Administrateur != null){
                    CGlobalCache.LstDemandeReservationSelectAll.Add(objDemandeReservationResult);
                }

                LoadDemandeReservation();

                if (callbackAction == null){
                    return;
                }
                callbackAction(objDemandeReservationResult);
            }, null);
        }
        private void ConfirmReservation(DemandeReservationBO objDemandeReservation, Action<ReservationBO> callbackAction)
        {
            var reservationIFacClient = new ReservationIFACClient();
            AsyncGuiReservationSelectByDemandeReservationId insertGuiSampleDemandeReservationDelegate = reservationIFacClient.SelectEnCoursValidByReservationId;
            insertGuiSampleDemandeReservationDelegate.BeginInvoke(CGlobalCache.SessionManager.Token, objDemandeReservation.DemandeReservationId, result => {
                var sampleInsertDemandeReservationDelegate = (AsyncGuiReservationSelectByDemandeReservationId)((AsyncResult)result).AsyncDelegate;
                var objReservationResult = sampleInsertDemandeReservationDelegate.EndInvoke(result);

                reservationIFacClient.Close();

                if (objReservationResult != null && CGlobalCache.SessionManager.IsAdministrateur) {
                    CGlobalCache.LstReservationSelectAll.Add(objReservationResult);
                }

                if (callbackAction == null){
                    return;
                }
                callbackAction(objReservationResult);
            }, null);
        }
 internal static void AddNewDemandeReservationByClient(DemandeReservationBO demandeReservationResult)
 {
     LstNewDemandeReservationByClient.Add(demandeReservationResult);
     ActualLstDemandeReservationEventHandlser(demandeReservationResult, new EventArgs());
 }
        private void dataGridDemandeReservation_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0) {
                return;
            }
            var objDataGridView = (DataGridView)sender;
            objDataGridView.Rows[e.RowIndex].Selected = true;

            if (objDataGridView.Columns[0].Name.Equals("Demande")){
                _reservationSelected = null;
                _demandeReservationSelected = CGlobalCache.LstDemandeReservationSelectAll.FirstOrDefault(xx => xx.DemandeReservationId.Equals(objDataGridView.Rows[e.RowIndex].Cells[0].Value));
                btnEmprunter.Enabled = false;
            }
            if (objDataGridView.Columns[0].Name.Equals("Reservation")){
                _demandeReservationSelected = null;
                _reservationSelected = CGlobalCache.LstReservationSelectAll.ToList().Find(xx => xx.ReservationId.Equals(objDataGridView.Rows[e.RowIndex].Cells[0].Value));
                btnEmprunter.Enabled = true;
            }
            btnAnnuler.Enabled = true;
            ShowDetailSelection();
        }
        private Boolean InsertDemandeReservation()
        {
            Boolean bResult = false;
            DemandeReservationBO objDemandeReservation = new DemandeReservationBO(), demandeReservationResult;
            objDemandeReservation.Client = CGlobalCache.SessionManager.Personne.Client;
            objDemandeReservation.RefLivre = _livreSelected.RefLivre;

            DemandeReservationIFACClient demandeReservationIFacClient = null;
            try {
                demandeReservationIFacClient = new DemandeReservationIFACClient();
                demandeReservationResult = demandeReservationIFacClient.InsertDemandeReservation(CGlobalCache.SessionManager.Token, objDemandeReservation);
            } catch (Exception ex) {
                throw;
            } finally {
                if (demandeReservationIFacClient != null) {
                    demandeReservationIFacClient.Close();
                }
            }
            if (demandeReservationResult != null) {
                CGlobalCache.AddNewDemandeReservationByClient(demandeReservationResult);
                bResult = true;
            }
            return bResult;
        }