public IHttpActionResult PutCustAddress(int id, CustAddress custAddress)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != custAddress.cust_id)
            {
                return(BadRequest());
            }

            db.Entry(custAddress).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustAddressExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult PutTransaction(int id, Transaction transaction)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != transaction.reference_id)
            {
                return(BadRequest());
            }

            db.Entry(transaction).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TransactionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public HttpResponseMessage AddBeneficiary(Beneficiary beneficiary)
        {
            try
            {
                if (beneficiary.b_account_number == beneficiary.account_number)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Same"));
                }
                var exists = db.Beneficiaries.FirstOrDefault(b => b.account_number == beneficiary.account_number && b.b_account_number == beneficiary.b_account_number);

                if (exists == null)
                {
                    db.Beneficiaries.Add(beneficiary);
                    db.SaveChanges();
                    return(Request.CreateResponse(HttpStatusCode.OK, "Okay"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Exists"));
                }
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }
                return(Request.CreateResponse(HttpStatusCode.OK, e.Message));
            }
        }
        public IHttpActionResult PutAccountDetail(long id, AccountDetail accountDetail)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != accountDetail.account_number)
            {
                return(BadRequest());
            }

            db.Entry(accountDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AccountDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #5
0
        public IHttpActionResult PutApproval(int id, Approval approval)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != approval.approval_id)
            {
                return(BadRequest());
            }

            db.Entry(approval).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApprovalExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #6
0
        public void Put(string allotted_to, int cust_id, [FromBody] Approval approval)
        {
            int admin_allot = Convert.ToInt32(allotted_to);

            approval = (from p in db.Approvals
                        where p.cust_id == cust_id
                        select p).SingleOrDefault();
            approval.alloted_to = admin_allot;
            db.SaveChanges();
        }
        public IHttpActionResult UpdateBalance(long from_account_number, long to_account_number, int debit, [FromBody] AccountDetail accountDetail)
        {
            accountDetail = (from p in db.AccountDetails
                             where p.account_number == from_account_number
                             select p).SingleOrDefault();
            accountDetail.current_balance -= debit;
            decimal balance = accountDetail.current_balance;

            accountDetail = (from p in db.AccountDetails
                             where p.account_number == to_account_number
                             select p).SingleOrDefault();
            accountDetail.current_balance += debit;
            db.SaveChanges();
            return(Ok(balance));
        }
 public void Put(int allotted_to, int cust_id, [FromBody] Approval approval)
 {
     approval = (from p in db.Approvals
                 where p.cust_id == cust_id
                 select p).SingleOrDefault();
     approval.alloted_to = allotted_to;
     db.SaveChanges();
 }
Beispiel #9
0
 public async void EditCustomerDetail(Customer customer)
 {
     foreach (Customer cust in await Query(customer))
     {
         cust.Balance   = customer.Balance;
         cust.Firstname = customer.Firstname;
         cust.Lastname  = customer.Lastname;
         cust.Othername = customer.Othername;
         cust.Phone     = customer.Phone;
         cust.Username  = customer.Username;
         cust.Password  = customer.Password;
     }
     try
     {
         db.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        public ActionResult VerificarCuenta(string id)
        {
            bool Status = false;

            using (BankingEntities db = new BankingEntities())
            {
                db.Configuration.ValidateOnSaveEnabled = false;

                var v = db.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    db.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Solicitud invalida";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }
Beispiel #11
0
 public void updatePersonalDetail(Customer customer)
 {
     customer = (Customer)db.Customers.Where(cust => cust.AccountNumber == customer.AccountNumber);
     db.Entry(customer).State = EntityState.Modified;
     db.SaveChanges();
 }
Beispiel #12
0
        public void Modifier(Agence obj)
        {
            try
            {
                #region Processus de teste
                // -- Si l'application est branché à la base de données -- //
                if (!AppSettings.CONNEXION_DB_BANKINGENTITIES)
                {
                    // -- Unicité du code -- //
                    if (Program.db.agences.Exists(l => l.id != obj.id && l.code == obj.code))
                    {
                        throw new GBException(App_Lang.Lang.Existing_data + " [code]");
                    }

                    // -- Modification de la valeur -- //
                    Program.db.agences
                    // -- Spécifier la recherche -- //
                    .Where(l => l.id == obj.id)
                    // -- Lister le résultat -- //
                    .ToList()
                    // -- Parcourir les elements résultats -- //
                    .ForEach(l =>
                    {
                        // -- Mise à jour de l'enregistrement -- //
                        l.code           = obj.code;
                        l.libelle        = obj.libelle;
                        l.id_utilisateur = obj.id_utilisateur;
                        l.utilisateur    = new UtilisateurDAO().ObjectId(obj.id_utilisateur);
                        l.adresse        = obj.adresse;
                        l.ville          = obj.ville;
                        l.bp             = obj.bp;
                        l.telephone      = obj.telephone;
                        l.pays           = obj.pays;
                        l.fax            = obj.fax;
                        l.cobac_id       = obj.cobac_id;
                        l.beac_id        = obj.beac_id;
                        l.ip             = obj.ip;
                        l.mot_de_passe   = obj.mot_de_passe;
                    });
                }
                #endregion

                #region Processus fonctionnel
                else
                {
                    // -- Définition du context -- //
                    using (BankingEntities db = new BankingEntities())
                    {
                        // -- Désactivation du Lasy loading -- //
                        db.Configuration.LazyLoadingEnabled = false;

                        // -- Rechercher l'objet à modifier -- //
                        agence ancien_obj = db.agences.Find(obj.code);

                        // -- Vérifier que l'objet est retournée -- //
                        if (ancien_obj == null)
                        {
                            throw new GBException(App_Lang.Lang.Object_not_found);
                        }

                        // -- Mise à jour de l'ancienne valeur -- //
                        obj.ModifyEntities(ancien_obj);

                        // -- Enregistrement de la données -- //
                        db.Entry <agence>(ancien_obj).State = System.Data.Entity.EntityState.Modified;

                        // -- Sauvegarder les changements -- //
                        db.SaveChanges();
                    }
                }
                #endregion

                // -- Execution des Hubs -- //
                #region Execution des Hubs
                applicationMainHub.RechargerCombo(new AgenceDAO());
                applicationMainHub.RechargerTable(this.id_page, this.connexion.hub_id_context);
                #endregion
            }
            #region Catch
            catch (Exception ex)
            {
                // -- Vérifier la nature de l'exception -- //
                if (!GBException.Est_GBexception(ex))
                {
                    // -- Log -- //
                    GBClass.Log.Error(ex);

                    // -- Renvoyer l'exception -- //
                    throw new GBException(App_Lang.Lang.Error_message_notification);
                }
                else
                {
                    // -- Renvoyer l'exception -- //
                    throw new GBException(ex.Message);
                }
            }
            #endregion
        }
Beispiel #13
0
        public IHttpActionResult Register(Registration registration)
        {
            CustomerDetail customer = new CustomerDetail
            {
                title               = registration.title,
                first_name          = registration.first_name,
                middle_name         = registration.middle_name,
                last_name           = registration.last_name,
                fathers_name        = registration.fathers_name,
                mobile_number       = registration.mobile_number,
                email               = registration.email,
                aadhar              = registration.aadhar,
                pan_card            = registration.pan_card,
                pan_doc             = registration.pan_doc,
                dob                 = registration.dob,
                occupation_type     = registration.occupation_type,
                source_of_income    = registration.source_of_income,
                gross_annual_income = registration.gross_annual_income,
                debit_card          = registration.debit_card,
                net_banking         = registration.net_banking,
                approval_status     = registration.approval_status
            };

            db.CustomerDetails.Add(customer);
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                while (e.InnerException != null)
                {
                    e = e.InnerException;
                }
                return(Ok(new { message = "Exception", exception_message = e.Message }));
            }

            registration.cust_id = db.CustomerDetails.FirstOrDefault(c => c.mobile_number == registration.mobile_number).cust_id;


            if (registration.type_of_address == "Yes")
            {
                db.CustAddresses.Add(new CustAddress
                {
                    cust_id         = registration.cust_id,
                    type_of_address = "same",
                    line1           = registration.line1,
                    line2           = registration.line2,
                    landmark        = registration.landmark,
                    city            = registration.city,
                    cust_state      = registration.cust_state,
                    pin_code        = registration.pin_code
                });
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(Ok(new { message = "Exception", exception_message = e.Message }));
                }
            }
            else
            {
                db.CustAddresses.Add(new CustAddress
                {
                    cust_id         = registration.cust_id,
                    type_of_address = "Permanent",
                    line1           = registration.line1,
                    line2           = registration.line2,
                    landmark        = registration.landmark,
                    city            = registration.city,
                    cust_state      = registration.cust_state,
                    pin_code        = registration.pin_code
                });
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(Ok(new { message = "Exception", exception_message = e.Message }));
                }
                db.CustAddresses.Add(new CustAddress
                {
                    cust_id         = registration.cust_id,
                    type_of_address = "Resident",
                    line1           = registration.line1_residential,
                    line2           = registration.line2_residential,
                    landmark        = registration.landmark_residential,
                    city            = registration.city_residential,
                    cust_state      = registration.cust_state_residential,
                    pin_code        = registration.pin_code_residential
                });
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(Ok(new { message = "Exception", exception_message = e.Message }));
                }
            }

            return(Ok(new { message = "Okay", customer.cust_id }));
        }
        public HttpResponseMessage UserLogin(int userid, string login_password)
        {
            bool          Exists = false;
            AccountHolder ah     = new AccountHolder();

            var user = (from acc_holder in db.AccountHolders
                        where acc_holder.user_id == userid
                        select acc_holder.login_password).FirstOrDefault();
            var a = user;

            if (a != null)
            {
                System.Text.UTF8Encoding encoder    = new System.Text.UTF8Encoding();
                System.Text.Decoder      utf8Decode = encoder.GetDecoder();
                byte[] todecode_byte = Convert.FromBase64String(a);
                int    charCount     = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
                char[] decoded_char  = new char[charCount];
                utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
                string decrypt_login_password = new String(decoded_char);


                List <AccountHolder> ahs = db.AccountHolders.ToList();
                foreach (var item in ahs)
                {
                    if (item.user_id == userid)
                    {
                        Exists = true;
                        ah     = item;
                        break;
                    }
                }

                if (Exists)
                {
                    int status = Convert.ToInt32(ah.account_status);
                    if (status < 3)
                    {
                        if (decrypt_login_password == login_password)
                        {
                            ah.account_status = "0";
                            db.SaveChanges();

                            if (ah.last_login == null)
                            {
                                if (ah.CustomerDetail.net_banking)
                                {
                                    ah.last_login = DateTime.Now;
                                    db.SaveChanges();
                                    return(Request.CreateResponse(HttpStatusCode.OK, "First Login"));
                                }
                                else
                                {
                                    ah.last_login = DateTime.Now;
                                    db.SaveChanges();
                                    return(Request.CreateResponse(HttpStatusCode.OK, "First Login Without Net Banking"));
                                }
                            }
                            else
                            {
                                ah.last_login = DateTime.Now;
                                db.SaveChanges();
                                if (ah.CustomerDetail.net_banking)
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, "Success"));
                                }
                                else
                                {
                                    return(Request.CreateResponse(HttpStatusCode.OK, "Success Without Net Banking"));
                                }
                            }
                        }

                        else
                        {
                            status += 1;
                            if (status >= 3)
                            {
                                ah.account_status = "3";
                                db.SaveChanges();
                                return(Request.CreateResponse(HttpStatusCode.OK, "Failed after 3 unsuccessful login attempts"));
                            }
                            else
                            {
                                ah.account_status = status.ToString();
                                db.SaveChanges();
                                return(Request.CreateResponse(HttpStatusCode.OK, "Wrong Password"));
                            }
                        }
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, "Account Already Locked!"));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "Invalid User id"));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Invalid User id"));
            }
        }
Beispiel #15
0
        private static void Mise_a_jour_devise_actuelle(string id)
        {
            try
            {
                #region Processus de teste
                // -- Si l'application est branché à la base de données -- //
                if (!AppSettings.CONNEXION_DB_BANKINGENTITIES)
                {
                    // -- Vérification de la nature de l'identifiant -- //
                    if (long.Parse(id) <= 0)
                    {
                        throw new GBException(App_Lang.Lang.The_object_must_have_a_unique_id);
                    }

                    Program.db.devises
                    .Where(l => l.id != id)
                    .ToList()
                    .ForEach(l =>
                    {
                        l.devise_actuelle = false;
                    }
                             );
                }
                #endregion

                #region Processus fonctionnel
                else
                {
                    // -- Définition du context -- //
                    using (BankingEntities db = new BankingEntities())
                    {
                        // -- Désactivation du Lasy loading -- //
                        db.Configuration.LazyLoadingEnabled = false;

                        // -- Rechercher l'objet à modifier -- //
                        devise ancien_obj = db.devises.Find(id);

                        // -- Vérifier que l'objet est retournée -- //
                        if (ancien_obj == null)
                        {
                            throw new GBException(App_Lang.Lang.Object_not_found);
                        }

                        // -- Mise à jour de l'ancienne valeur -- //
                        ancien_obj.CurrentCurrency = "No";

                        // -- Enregistrement de la données -- //
                        db.Entry <devise>(ancien_obj).State = System.Data.Entity.EntityState.Modified;

                        // -- Sauvegarder les changements -- //
                        db.SaveChanges();
                    }
                }
                #endregion
            }
            #region Catch
            catch (Exception ex)
            {
                // -- Vérifier la nature de l'exception -- //
                if (!GBException.Est_GBexception(ex))
                {
                    // -- Log -- //
                    GBClass.Log.Error(ex);

                    // -- Renvoyer l'exception -- //
                    throw new GBException(App_Lang.Lang.Error_message_notification);
                }
                else
                {
                    // -- Renvoyer l'exception -- //
                    throw new GBException(ex.Message);
                }
            }
            #endregion
        }
 public void AddTransaction(Transaction transaction)
 {
     db.Transactions.Add(transaction);
     db.SaveChanges();
 }
        public ActionResult Registro(User user)
        {
            bool   Status  = false;
            string message = "";

            // Model Validation
            if (ModelState.IsValid)
            {
                #region Si el correo ya existe
                var Existe = CorreoExist(user.Correo);
                if (Existe)
                {
                    message = "Este correo ya existe";
                    ModelState.AddModelError("CorreoExiste", message);
                    log.Error(message);
                    return(View(user));
                }
                #endregion

                #region Generate Activation Code
                user.ActivationCode = Guid.NewGuid();
                #endregion

                #region  Password Hashing
                user.Password        = Crypto.Hash(user.Password);
                user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword); //
                #endregion

                user.IsEmailVerified = false;

                #region Save to Database

                try
                {
                    using (BankingEntities db = new BankingEntities())
                    {
                        db.Users.Add(user);
                        db.SaveChanges();

                        //Send Email to User
                        SendVerificationLinkEmail(user.Correo, user.ActivationCode.ToString());
                        message = $"\tEl registro ha sido realizado con exito. El link de activacion ha sido enviado a tu correo : {user.Correo} ";
                        log.Info(message);

                        Status = true;
                    }
                }
                catch (Exception ex)
                {
                    message = "Error al agregar usuario - ";
                    ModelState.AddModelError("", message + ex.Message);
                    log.Error(message + ex.Message);
                }

                #endregion
            }
            else
            {
                message = "\tSolicitud invalida";
                log.Error(message);
            }

            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(user));
        }
Beispiel #18
0
        public void Modifier(Utilisateur obj)
        {
            try
            {
                #region Processus de teste
                // -- Si l'application est branché à la base de données -- //
                if (!AppSettings.CONNEXION_DB_BANKINGENTITIES)
                {
                    // -- Unicité du code -- //
                    if (Program.db.utilisateurs.Exists(l => l.id_utilisateur != obj.id_utilisateur && l.compte == obj.compte))
                    {
                        throw new GBException(App_Lang.Lang.Existing_data + " [compte]");
                    }

                    // -- Modification de la valeur -- //
                    Program.db.utilisateurs
                    // -- Spécifier la recherche -- //
                    .Where(l => l.id_utilisateur == obj.id_utilisateur)
                    // -- Lister le résultat -- //
                    .ToList()
                    // -- Parcourir les elements résultats -- //
                    .ForEach(l =>
                    {
                        // -- Mise à jour de l'enregistrement -- //
                        l.compte                        = obj.compte;
                        l.nom_utilisateur               = obj.nom_utilisateur;
                        l.id_agence                     = obj.id_agence;
                        l.agence                        = new AgenceDAO().ObjectId(obj.id_agence);
                        l.id_profession                 = obj.id_profession;
                        l.profession                    = new ProfessionDAO().ObjectId(obj.id_profession);
                        l.id_autorite_signature         = obj.id_autorite_signature;
                        l.autorite_signature            = new AutoriteSignatureDAO().ObjectId(obj.id_autorite_signature);
                        l.ouverture_back_date           = obj.ouverture_back_date;
                        l.ouverture_back_date_travail   = obj.ouverture_back_date_travail;
                        l.ouverture_branch              = obj.ouverture_branch;
                        l.est_connecte                  = obj.est_connecte;
                        l.est_suspendu                  = obj.est_suspendu;
                        l.duree_mot_de_passe            = obj.duree_mot_de_passe;
                        l.date_mise_a_jour_mot_de_passe = DateTime.Now.AddMonths(obj.duree_mot_de_passe).Ticks;
                        // -- Mise à jour du mot de passe -- //
                        if (obj.modifier_mot_de_passe)
                        {
                            l.mot_de_passe = obj.mot_de_passe;
                        }
                    });
                }
                #endregion

                #region Processus fonctionnel
                else
                {
                    // -- Définition du context -- //
                    using (BankingEntities db = new BankingEntities())
                    {
                        // -- Désactivation du Lasy loading -- //
                        db.Configuration.LazyLoadingEnabled = false;

                        // -- Rechercher l'objet à modifier -- //
                        Employe ancien_obj = db.Employes.Find(obj.code);

                        // -- Vérifier que l'objet est retournée -- //
                        if (ancien_obj == null)
                        {
                            throw new GBException(App_Lang.Lang.Object_not_found);
                        }

                        // -- Mise à jour de l'ancienne valeur -- //
                        obj.ModifyEntities(ancien_obj);

                        // -- Enregistrement de la données -- //
                        db.Entry <Employe>(ancien_obj).State = System.Data.Entity.EntityState.Modified;

                        // -- Sauvegarder les changements -- //
                        db.SaveChanges();
                    }
                }
                #endregion

                // -- Execution des Hubs -- //
                applicationMainHub.RechargerTable(this.id_page, this.connexion.hub_id_context);
                applicationMainHub.RechargerComboEasyAutocomplete(this, this.connexion.hub_id_context);
            }
            #region Catch
            catch (Exception ex)
            {
                // -- Vérifier la nature de l'exception -- //
                if (!GBException.Est_GBexception(ex))
                {
                    // -- Log -- //
                    GBClass.Log.Error(ex);

                    // -- Renvoyer l'exception -- //
                    throw new GBException(App_Lang.Lang.Error_message_notification);
                }
                else
                {
                    // -- Renvoyer l'exception -- //
                    throw new GBException(ex.Message);
                }
            }
            #endregion
        }
Beispiel #19
0
        public void Supprimer(List <string> ids)
        {
            try
            {
                #region Processus de teste
                // -- Si l'application est branché à la base de données -- //
                if (!AppSettings.CONNEXION_DB_BANKINGENTITIES)
                {
                    // -- Parcours de la liste des id -- //
                    ids.ForEach(id =>
                    {
                        // -- Suppression des valeurs -- //
                        Program.db.agences.RemoveAll(l => l.id == id);
                    });
                }
                #endregion

                #region Processus fonctionnel
                else
                {
                    // -- Définition du context -- //
                    using (BankingEntities db = new BankingEntities())
                    {
                        // -- Désactivation du Lasy loading -- //
                        db.Configuration.LazyLoadingEnabled = false;

                        // -- Supprimer la liste -- //
                        db.agences.RemoveRange(
                            // -- Réccupérer les éléments à supprimer -- //
                            db.agences.Where(l => ids.Count(ll => ll.Equals(l.agcod)) != 0)
                            );

                        // -- Sauvegarder les changements -- //
                        db.SaveChanges();
                    }
                }
                #endregion

                // -- Execution des Hubs -- //
                #region Execution des Hubs
                applicationMainHub.RechargerCombo(new AgenceDAO());
                applicationMainHub.RechargerTable(this.id_page, this.connexion.hub_id_context);
                #endregion
            }
            #region Catch
            catch (Exception ex)
            {
                // -- Vérifier la nature de l'exception -- //
                if (!GBException.Est_GBexception(ex))
                {
                    // -- Log -- //
                    GBClass.Log.Error(ex);

                    // -- Renvoyer l'exception -- //
                    throw new GBException(App_Lang.Lang.Error_message_notification);
                }
                else
                {
                    // -- Renvoyer l'exception -- //
                    throw new GBException(ex.Message);
                }
            }
            #endregion
        }
Beispiel #20
0
        public void Ajouter(Agence obj, string id_utilisateur = null)
        {
            try
            {
                #region Processus de teste
                // -- Si l'application est branché à la base de données -- //
                if (!AppSettings.CONNEXION_DB_BANKINGENTITIES)
                {
                    // -- Unicité du code -- //
                    if (Program.db.agences.Exists(l => l.code == obj.code))
                    {
                        throw new GBException(App_Lang.Lang.Existing_data + " [code]");
                    }

                    // -- Définition de l'identifiant -- //
                    obj.Crer_Id();

                    // -- Mise à jour des references -- //
                    obj.utilisateur = new UtilisateurDAO().ObjectId(obj.id_utilisateur);

                    // -- Enregistrement de la valeur -- //
                    Program.db.agences.Add(obj);
                }
                #endregion

                #region Processus fonctionnel
                else
                {
                    // -- Définition du context -- //
                    using (BankingEntities db = new BankingEntities())
                    {
                        // -- Désactivation du Lasy loading -- //
                        db.Configuration.LazyLoadingEnabled = false;

                        // -- Définition des variables -- //
                        Dictionary <string, object> parametres = new Dictionary <string, object>();
                        parametres.Add("date_creation", this.connexion.date_serveur);

                        // -- Enregistrement de la données -- //
                        db.agences.Add(obj.ToEntities(parametres));

                        // -- Sauvegarder les changements -- //
                        db.SaveChanges();
                    }
                }
                #endregion

                // -- Execution des Hubs -- //
                #region Execution des Hubs
                applicationMainHub.RechargerCombo(new AgenceDAO());
                applicationMainHub.RechargerTable(this.id_page, this.connexion.hub_id_context);
                #endregion
            }
            #region Catch
            catch (Exception ex)
            {
                // -- Vérifier la nature de l'exception -- //
                if (!GBException.Est_GBexception(ex))
                {
                    // -- Log -- //
                    GBClass.Log.Error(ex);

                    // -- Renvoyer l'exception -- //
                    throw new GBException(App_Lang.Lang.Error_message_notification);
                }
                else
                {
                    // -- Renvoyer l'exception -- //
                    throw new GBException(ex.Message);
                }
            }
            #endregion
        }
Beispiel #21
0
        public void Modifier(AutoriteSignature obj)
        {
            try
            {
                #region Processus de teste
                // -- Si l'application est branché à la base de données -- //
                if (!AppSettings.CONNEXION_DB_BANKINGENTITIES)
                {
                    // -- Unicité du code -- //
                    if (Program.db.autorites_signature.Exists(l => l.id != obj.id && l.code == obj.code))
                    {
                        throw new GBException(App_Lang.Lang.Existing_data + " [code]");
                    }

                    // -- Modification de la valeur -- //
                    Program.db.autorites_signature
                    // -- Spécifier la recherche -- //
                    .Where(l => l.id == obj.id)
                    // -- Lister le résultat -- //
                    .ToList()
                    // -- Parcourir les elements résultats -- //
                    .ForEach(l =>
                    {
                        // -- Mise à jour de l'enregistrement -- //
                        l.code                     = obj.code;
                        l.libelle                  = obj.libelle;
                        l.montant_signature        = obj.montant_signature;
                        l.limite_decouvert_client  = obj.limite_decouvert_client;
                        l.debit_max_client         = obj.debit_max_client;
                        l.credit_max_client        = obj.credit_max_client;
                        l.montant_max_ligne_credit = obj.montant_max_ligne_credit;
                        l.montant_limite_pret      = obj.montant_limite_pret;
                    });
                }
                #endregion

                #region Processus fonctionnel
                else
                {
                    // -- Définition du context -- //
                    using (BankingEntities db = new BankingEntities())
                    {
                        // -- Désactivation du Lasy loading -- //
                        db.Configuration.LazyLoadingEnabled = false;

                        // -- Rechercher l'objet à modifier -- //
                        tabSigningAuthority ancien_obj = db.tabSigningAuthorities.Find(obj.code);

                        // -- Vérifier que l'objet est retournée -- //
                        if (ancien_obj == null)
                        {
                            throw new GBException(App_Lang.Lang.Object_not_found);
                        }

                        // -- Mise à jour de l'ancienne valeur -- //
                        obj.ModifyEntities(ancien_obj);

                        // -- Enregistrement de la données -- //
                        db.Entry <tabSigningAuthority>(ancien_obj).State = System.Data.Entity.EntityState.Modified;

                        // -- Sauvegarder les changements -- //
                        db.SaveChanges();
                    }
                }
                #endregion

                #region Execution des Hubs
                // -- Execution des Hubs -- //
                applicationMainHub.RechargerTable(this.id_page, this.connexion.hub_id_context);
                applicationMainHub.RechargerComboEasyAutocomplete(this, this.connexion.hub_id_context);
                #endregion
            }
            #region Catch
            catch (Exception ex)
            {
                // -- Vérifier la nature de l'exception -- //
                if (!GBException.Est_GBexception(ex))
                {
                    // -- Log -- //
                    GBClass.Log.Error(ex);

                    // -- Renvoyer l'exception -- //
                    throw new GBException(App_Lang.Lang.Error_message_notification);
                }
                else
                {
                    // -- Renvoyer l'exception -- //
                    throw new GBException(ex.Message);
                }
            }
            #endregion
        }