Exemple #1
0
        //Obtiene las cuentas con deuda
        public IEnumerable <AccountDTO> GetAccountsWithDebt(AccountManagerDbContext pContext)
        {
            List <AccountDTO> mAccountWithDebt = new List <AccountDTO>();

            using (var bUnitOfWork = new UnitOfWork(new AccountManagerDbContext()))
            {
                //Verifica cada cuenta de cada cliente
                foreach (Client bClient in pContext.Clients)
                {
                    foreach (Account bAccount in bClient.Accounts)
                    {
                        if ((bAccount.GetBalance()) < (bAccount.OverdraftLimit * -1))       //Si el balance es menor al negativo del limite de descubierto
                        {
                            mAccountWithDebt.Add(new AccountDTO
                            {
                                Id             = bAccount.Id,
                                Name           = bAccount.Name,
                                OverDraftLimit = bAccount.OverdraftLimit,
                                Balance        = bAccount.GetBalance()
                            });
                        }
                    }
                }

                bUnitOfWork.Complete();
            }

            return(mAccountWithDebt);
        }
Exemple #2
0
        //Agrega un nuevo cliente
        public void AddClient(AccountManagerDbContext pContext, String pDocument,
                              String pDocumentType, String pName, String pSurname)
        {
            DocumentType iDocT;

            //Verifica que tipo de documento de identidad selecciono.
            if (pDocumentType == "CUIL")
            {
                iDocT = DocumentType.CUIL;
            }
            else if (pDocumentType == "DNI")
            {
                iDocT = DocumentType.DNI;
            }
            else if (pDocumentType == "LC")
            {
                iDocT = DocumentType.LC;
            }
            else
            {
                iDocT = DocumentType.LE;
            }

            using (var bUnitOfWork = new UnitOfWork(new AccountManagerDbContext()))
            {
                Client iCliente = new Client
                {
                    Document = new Document
                    {
                        Type   = iDocT,
                        Number = pDocument
                    },
                    FirstName = pName,
                    LastName  = pSurname,

                    Accounts = new List <Account> {
                    }
                };

                bUnitOfWork.ClientRepository.Add(iCliente);

                bUnitOfWork.Complete();
            }
        }
Exemple #3
0
        //Busca el id del cliente por numero de documento
        public int SearchIdClientByNumDoc(AccountManagerDbContext pContext, String pNumDoc)
        {
            int idClient = 0;

            using (var bUnitOfWork = new UnitOfWork(new AccountManagerDbContext()))
            {
                //foreach (var bClient in bUnitOfWork.ClientRepository.GetAll())
                foreach (Client bClient in pContext.Clients)
                {
                    //if (bClient.Document.Equals(pNumDoc))
                    if (bClient.Document.Number.Equals(pNumDoc))
                    {
                        idClient = bClient.Id;
                        return(idClient);
                    }
                }
            }
            return(idClient);
        }