Пример #1
0
        //-- END GET STATISTICAL LINE CHECK

        //-- GET LIST CHECK BY EMPLOYE
        public List <PaymentCheckDTO> GetListCheckByEmploye(int idEmploye)
        {
            List <PaymentCheckDTO> paymentsChequeDTO = new List <PaymentCheckDTO>();

            foreach (Cheque cheque in  _context
                     .Cheques
                     .Include(c => c.Compte)
                     .Where(c => c.Employe.CodePersonne == idEmploye)
                     .ToList())
            {
                PaymentCheckDTO paymentCheckDTO = new PaymentCheckDTO();
                paymentCheckDTO.BankName           = cheque.BankName;
                paymentCheckDTO.CINProprietaire    = cheque.CINProprietaire;
                paymentCheckDTO.DateV              = cheque.DateV;
                paymentCheckDTO.IdC                = cheque.idC;
                paymentCheckDTO.Montant            = cheque.Montant;
                paymentCheckDTO.NomProprietaire    = cheque.NomProprietaire;
                paymentCheckDTO.NumeroC            = cheque.NumeroC;
                paymentCheckDTO.PrenomProprietaire = cheque.PrenomProprietaire;

                paymentCheckDTO.CodeCompte   = _context.Comptes.Find(cheque.Compte.CodeCompte).CodeCompte;
                paymentCheckDTO.DateCreation = _context.Comptes.Find(cheque.Compte.CodeCompte).DateCreation;
                paymentCheckDTO.Decouvert    = _context.Comptes.Find(cheque.Compte.CodeCompte).Decouvert;
                paymentCheckDTO.Solde        = _context.Comptes.Find(cheque.Compte.CodeCompte).Solde;
                paymentCheckDTO.Taux         = _context.Comptes.Find(cheque.Compte.CodeCompte).Taux;
                paymentCheckDTO.Type         = _context.Comptes.Find(cheque.Compte.CodeCompte).Type;
                paymentsChequeDTO.Add(paymentCheckDTO);
            }
            return(paymentsChequeDTO);
        }
Пример #2
0
        //-- END GET LIST CHECK BY EMPLOYE

        //-- Payment Cheque Operation
        public Cheque VersementCheque(PaymentCheckDTO c)
        {
            c.DateV = DateTime.Now;

            if (c.CodeCompte == null)
            {
                throw new NullReferenceException("Account Number Must not be null ");
            }

            Compte compte = _context.Comptes.Find(c.CodeCompte);

            //-- EXCEPTION
            if (c.BankName == null || c.CINProprietaire == 0 || c.Montant == 0 || c.NomProprietaire == null || c.NumeroC == 0 || c.PrenomProprietaire == null)
            {
                throw new NullReferenceException("Some Information Are Not Loaded Correctly Try Again ");
            }

            if (c.CINProprietaire.ToString().Length != 8)
            {
                throw new NullReferenceException("Identity Number Must Be Composed From 8 Number ");
            }

            if (c.NumeroC.ToString().Length != 11)
            {
                throw new NullReferenceException("Check Number Must Be Composed From 11 Number ");
            }
            //-- END EXCEPTION

            Cheque cheque = new Cheque();

            cheque.BankName           = c.BankName;
            cheque.CINProprietaire    = c.CINProprietaire;
            cheque.Compte             = compte;
            cheque.DateV              = c.DateV;
            cheque.idC                = c.IdC;
            cheque.Montant            = c.Montant;
            cheque.NomProprietaire    = c.NomProprietaire;
            cheque.NumeroC            = c.NumeroC;
            cheque.PrenomProprietaire = c.PrenomProprietaire;
            cheque.Employe            = _context.Employes.Find(c.IdEmploye);

            //-- SAVING DATA IN DATABASE
            _context.Cheques.Add(cheque);
            //-- END SAVING DATA IN DATABASE
            compte.Solde += cheque.Montant;
            //-- COMIITING
            Save();
            //-- END COMMITING

            return(cheque);
        }
Пример #3
0
        public PaymentCheckDTO VersementCheque([FromBody] PaymentCheckDTO c)
        {
            //-- INSTANTIATION
            PaymentCheckDTO paymentCheckDTO = new PaymentCheckDTO();

            //-- END INSTANTIATION

            try
            {
                Cheque cheque = _chequeRepository.VersementCheque(c);
                //-- GETTING DATA FROM DAO AND TRANSFER IT TO DTO
                paymentCheckDTO.BankName           = cheque.BankName;
                paymentCheckDTO.CINProprietaire    = cheque.CINProprietaire;
                paymentCheckDTO.DateV              = cheque.DateV;
                paymentCheckDTO.IdC                = cheque.idC;
                paymentCheckDTO.Montant            = cheque.Montant;
                paymentCheckDTO.NomProprietaire    = cheque.NomProprietaire;
                paymentCheckDTO.NumeroC            = cheque.NumeroC;
                paymentCheckDTO.PrenomProprietaire = cheque.PrenomProprietaire;

                paymentCheckDTO.CodeCompte   = cheque.Compte.CodeCompte;
                paymentCheckDTO.DateCreation = cheque.Compte.DateCreation;
                paymentCheckDTO.Decouvert    = cheque.Compte.Decouvert;
                paymentCheckDTO.Solde        = cheque.Compte.Solde;
                paymentCheckDTO.Taux         = cheque.Compte.Taux;
                paymentCheckDTO.Type         = cheque.Compte.Type;

                paymentCheckDTO.MessageResult = "Operation Payment Check Done Successfully";
                //-- END GETTING DATA FROM DAO AND TRANSFER IT TO DTO
            }
            catch (NullReferenceException Exception)
            {
                paymentCheckDTO.MessageResult = Exception.Message;
            }
            return(paymentCheckDTO);
        }