예제 #1
0
        public async Task <ActionResult <Compte> > GetCompte(int id)
        {
            try
            {
                var result = await compteRepository.GetCompte(id);

                if (result == null)
                {
                    return(NotFound());
                }

                return(result);
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  "Error retrieving data from the database"));
            }
        }
예제 #2
0
        public CompteDTO GetCompte(String id)
        {
            //-- INSTANTIATION && ATTRIBUTS
            CompteDTO compteDTO = new CompteDTO();

            //-- END INSTATIATION && ATTRIBUTS
            try
            {
                //-- GETTING ACCOUNT INFORMATIONS
                Compte compte = _compteRepository.GetCompte(id);
                List <OperationCompteDTO> operationsCompteDTO = new List <OperationCompteDTO>();
                //-- END GETTING ACCOUNT INFORMATIONS


                //-- TRANSFER DATA TO DTO
                compteDTO.CodeCompte   = compte.CodeCompte;
                compteDTO.DateCreation = compte.DateCreation;
                compteDTO.Decouvert    = compte.Decouvert;
                compteDTO.Solde        = compte.Solde;
                compteDTO.Taux         = compte.Taux;
                compteDTO.Type         = compte.Type;
                compteDTO.CodeClient   = compte.client.CodePersonne;
                compteDTO.NomClient    = compte.client.NomPersonne;

                foreach (Operation operation in compte.Operations)
                {
                    OperationCompteDTO operationCompteDTO = new OperationCompteDTO();

                    operationCompteDTO.NumeroOperation = operation.NumeroOperation;
                    operationCompteDTO.DateOperation   = operation.DateOperation;
                    operationCompteDTO.Montant         = operation.Montant;
                    operationCompteDTO.TypeO           = operation.TypeO;

                    operationsCompteDTO.Add(operationCompteDTO);
                }
                compteDTO.OperationCompteDTO = operationsCompteDTO;
                compteDTO.ResultMessage      = "ACCOUNT INFORMATIONS LOADED SUCCESSFULLY";
                //-- END TRANSFER DATA TO DTO
            }
            catch (NullReferenceException exception)
            {
                compteDTO.ResultMessage = exception.Message;
                System.Diagnostics.Debug.WriteLine(exception.Message);
            }
            return(compteDTO);
        }