Пример #1
0
 public GetCustomerByCPFCommandResult(bool success, string message, GetCustomerByCPFCommandOutput data, int statusCode, IEnumerable <Notification> notifications)
 {
     Success       = success;
     Message       = message;
     Data          = data;
     StatusCode    = statusCode;
     Notifications = notifications;
 }
Пример #2
0
        public async ValueTask <GetCustomerByCPFCommandResult> Handle(GetCustomerByCPFCommandInput command)
        {
            command.Validate();
            if (command.Invalid)
            {
                return(new GetCustomerByCPFCommandResult(false, "Incorrect  data!", null, StatusCodes.Status400BadRequest, command.Notifications));
            }

            CustomersJson customerRepository = await _customerJsonRepository.GetCustomerByCpf(command);

            if (customerRepository == null)
            {
                return(new GetCustomerByCPFCommandResult(false, "NotFound", null, StatusCodes.Status404NotFound, command.Notifications));
            }

            Customer customer = new Customer(customerRepository.Id, customerRepository.Name, customerRepository.Cpf, customerRepository.Salary);

            customer.SalaryCustomerCalculation();

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

            return(new GetCustomerByCPFCommandResult(true, "Success!", customerByCPFcommandOutput, StatusCodes.Status200OK, command.Notifications));
        }