예제 #1
0
 public GetCustomerByIdCommandResult(bool success, string message, GetCustomerByIdCommandOutPut data, int statusCode, IEnumerable <Notification> notifications)
 {
     Success       = success;
     Message       = message;
     Data          = data;
     StatusCode    = statusCode;
     Notifications = notifications;
 }
예제 #2
0
        public async ValueTask <IActionResult> GetCustomers(int idCustomer)
        {
            try
            {
                var customer = await _customerJsonRepository.GetCustomerById(new GetCustomerByIdCommandInput { IdCustomer = idCustomer });

                if (customer == null)
                {
                    return(GetResult(new GetCustomerByIdCommandResult(false, "NotFound", null, StatusCodes.Status404NotFound, null)));
                }

                GetCustomerByIdCommandOutPut GetCustomerByCPFCommandOutput = new GetCustomerByIdCommandOutPut(customer.Id, customer.Name, customer.Cpf, customer.Salary);

                return(GetResult(new GetCustomerByIdCommandResult(true, "Success", GetCustomerByCPFCommandOutput, StatusCodes.Status200OK, null)));
            }
            catch (Exception exception)
            {
                _logger.LogError("An exception has occurred at {dateTime}. " +
                                 "Exception message: {message}." +
                                 "Exception Trace: {trace}", DateTime.UtcNow, exception.Message, exception.StackTrace);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }