/// <summary>
        /// The Execute
        /// </summary>
        /// <param name="input">The input<see cref="RegisterUserInput"/></param>
        /// <returns>The <see cref="Task"/></returns>
        public async Task Execute(RegisterUserInput input)
        {
            if (input is null)
            {
                _outputPort.WriteError(Messages.InputIsNull);
                _logger.LogInformation("Input is null");
                return;
            }


            _logger.LogInformation("Validation ok, Registering new user detail..");

            input.User.Guid = Guid.NewGuid().ToString();

            await _userRepository.Insert(input.User);

            var lastInsertedId = 1;

            if (lastInsertedId <= 0)
            {
                _logger.LogInformation(Messages.CouldNotRegister);
                this._outputPort.NotFound(Messages.CouldNotRegister);

                return;
            }

            var output = new RegisterUserOutput
            {
                Id = lastInsertedId
            };

            _outputPort.Standard(output);
        }
        public async Task Execute(RegisterInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var customer = _entityFactory.NewCustomer(input.SSN, input.Name);
            var account  = _entityFactory.NewAccount(customer);

            ICredit credit = account.Deposit(_entityFactory, input.InitialAmount);

            if (credit == null)
            {
                _outputHandler.Error("An error happened when depositing the amount.");
                return;
            }

            customer.Register(account);

            await _customerRepository.Add(customer);

            await _accountRepository.Add(account, credit);

            await _unitOfWork.Save();

            RegisterOutput output = new RegisterOutput(customer, account);

            _outputHandler.Standard(output);
        }
예제 #3
0
        private void BuildOutput(ICredit credit, IAccount account)
        {
            var output = new DepositOutput(
                credit,
                account.GetCurrentBalance());

            _outputPort.Standard(output);
        }
예제 #4
0
        private void BuildOutput(IDebit debit, IAccount account)
        {
            var output = new WithdrawOutput(
                debit,
                account.GetCurrentBalance());

            _outputPort.Standard(output);
        }
예제 #5
0
        public async Task Execute(RegisterInput input)
        {
            var customer = _entityFactory.NewCustomer(input.SSN, input.Name);
            var account  = _entityFactory.NewAccount(customer);

            var credit = account.Deposit(_entityFactory, input.InitialAmount);

            customer.Register(account);

            await _customerRepository.Add(customer);

            await _accountRepository.Add(account, credit);

            await _unitOfWork.Save();

            var output = new RegisterOutput(customer, account);

            _outputHandler.Standard(output);
        }
예제 #6
0
        public void BuildOutput(IDebit debit, IAccount originAccount, IAccount destinationAccount)
        {
            var output = new TransferOutput(
                debit,
                originAccount.GetCurrentBalance(),
                originAccount.Id,
                destinationAccount.Id);

            _outputPort.Standard(output);
        }
예제 #7
0
 public void Execute(CustomerSaveRequest request)
 {
     try
     {
         validateHandler.ProcessRequest(request);
         output.Standard(request.Customer.Id);
     }
     catch (Exception ex)
     {
         output.Error($"Error on process: {ex.Message}");
     }
 }
예제 #8
0
        public void BuildOutput(
            ExternalUserId externalUserId,
            ICustomer customer,
            IAccount account)
        {
            var output = new RegisterOutput(
                externalUserId,
                customer,
                account);

            _outputPort.Standard(output);
        }
예제 #9
0
 public void Execute()
 {
     try
     {
         var customers = customerReadOnlyRepository.GetAll();
         output.Standard(customers);
     }
     catch (System.Exception ex)
     {
         output.Error($"Error on process: {ex.Message}");
     }
 }
예제 #10
0
        private void BuildOutput(
            ExternalUserId externalUserId,
            ICustomer customer,
            List <Boundaries.GetCustomerDetails.Account> accounts)
        {
            var output = new GetCustomerDetailsOutput(
                externalUserId,
                customer,
                accounts);

            _outputPort.Standard(output);
        }
예제 #11
0
        public void Execute()
        {
            IEnumerable <domain.WeatherForecast> weathers;

            try
            {
                weathers = getWeather.Get();
                output.Standard(weathers);
            }
            catch (System.Exception e)
            {
                output.Error(e.Message);
            }
        }
예제 #12
0
        /// <inheritdoc/>
        public async Task Execute(CreateSpaceInput input)
        {
            try
            {
                ISpace space = await _spaceService.CreateSpace(input.SpaceName);

                _outputPort.Standard(new CreateSpaceOutput(space));
            }
            catch (SpaceAlreadyExistsException e)
            {
                _outputPort.SpaceAlreadyExists(e.Message);
            }
            catch (UnableToCreateSpaceException e)
            {
                _outputPort.UnableToCreateSpace(e.Message);
            }
        }
예제 #13
0
 public void Execute(CustomerDeleteRequest request)
 {
     try
     {
         var ret = customerWriteOnlyRepository.Delete(request.CustomerId);
         if (ret == 0)
         {
             output.Error($"Error on process Delete Customer");
             return;
         }
         output.Standard(request.CustomerId);
     }
     catch (Exception ex)
     {
         output.Error($"Error on process: {ex.Message}");
     }
 }
예제 #14
0
 public void Execute(CustomerGetRequest request)
 {
     try
     {
         var customer = customerReadOnlyRepository.GetById(request.CustomerId);
         if (customer == null)
         {
             output.NotFound($"Not found customer with id: {request.CustomerId}");
             return;
         }
         output.Standard(customer);
     }
     catch (Exception ex)
     {
         output.Error($"Error on process: {ex.Message}");
     }
 }
예제 #15
0
        public async Task Execute(AirlineInput airlineInput)
        {
            if (airlineInput == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var airline = new Airline()
            {
                Name        = airlineInput.Airline.Name,
                Description = airlineInput.Airline.Description,
                Planes      = airlineInput.Airline.Planes
            };
            await _airlineRepository.Add(airline);

            var airlineOutput = new AirlineOutput(airline);

            _outputHandler.Standard(airlineOutput);
        }
예제 #16
0
        public async Task Execute(AuthenticationInput input)
        {
            var client = await _clientRepository.GetUserByCredentials(
                input.Login,
                CryptUtils.EncryptPassword(input.Password)
                );

            if (client == null)
            {
                return;
            }

            _outputHandler.Standard(new AuthenticationOutput(
                                        client.Id,
                                        client.Name,
                                        client.Surname,
                                        client.Email,
                                        client.PhoneNumber,
                                        ""));
        }
        public async Task Execute(DestinationInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var destinations = input.Destinations.Select(d =>
                                                         new Destination()
            {
                AirlineId = d.AirlineId,
                Country   = d.Country
            }).ToList();

            await _destinationRepository.Add(destinations);

            var airlineOutput = new DestinationOutput(destinations);

            _outputHandler.Standard(airlineOutput);
        }
예제 #18
0
        public async Task Execute(RegisterInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var customer = _entityFactory.NewCustomer(input.SSN, input.Name);
            var account  = _entityFactory.NewAccount(customer);

            ICredit credit = account.Deposit(_entityFactory, input.InitialAmount);

            if (credit == null)
            {
                _outputHandler.Error("An error happened when depositing the amount.");
                return;
            }

            customer.Register(account);

            // Call to an external Web Api

            await _customerRepository.Add(customer);

            await _accountRepository.Add(account, credit);

            // Publish the event to the enterprice service bus
            await _serviceBus.PublishEventAsync(new RegistrationCompleted()
            {
                CustomerId = customer.Id, AccountId = account.Id, CreditId = credit.Id
            });

            await _unitOfWork.Save();


            RegisterOutput output = new RegisterOutput(customer, account);

            _outputHandler.Standard(output);
        }
예제 #19
0
        /// <inheritdoc/>
        public async Task Execute(CreatePageInput input)
        {
            try
            {
                ISpace space = await _spaceRepository.Get(input.SpaceName);

                IPage page = await _pageService.CreatePage(space, input.PageName, input.Content);

                _outputPort.Standard(new CreatePageOutput(page));
            }
            catch (SpaceNotFoundException e)
            {
                _outputPort.SpaceNotFound(e.Message);
            }
            catch (PageAlreadyExistsException e)
            {
                _outputPort.PageAlreadyExists(e.Message);
            }
            catch (UnableToCreatePageException e)
            {
                _outputPort.UnableToCreatePage(e.Message);
            }
        }
예제 #20
0
        public async Task Execute(CreateClientInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var client = new User()
            {
                Name        = input.Name,
                Surname     = input.Surname,
                PhoneNumber = input.PhoneNumber,
                Email       = input.Email,
                Password    = CryptUtils.EncryptPassword(input.Password),
                Role        = Role.Client
            };
            await _clientRepository.Register(client);

            var createClientOutput = new CreateClientOutput(client.Name, client.Surname, client.PhoneNumber, client.Email);

            _outputHandler.Standard(createClientOutput);
        }
        public async Task Execute(CreateOrderInput input)
        {
            if (input == null)
            {
                _outputHandler.Error("Input is null.");
                return;
            }

            var parcel = new Parcel()
            {
                Name        = input.ParcelName,
                Description = input.ParcelDescription
            };
            var Parcel = await _parcelRepository.AddParcel(parcel);

            var order = new Order()
            {
                SenderId             = input.SenderId,
                RecipientName        = input.RecipientName,
                RecipientSurname     = input.RecipientSurname,
                RecipientPhonenumber = input.RecipientPhoneNumber,
                ParcelId             = Parcel.Id,
                Status = input.Status
            };
            await _orderRepository.RegisterOrder(order);

            var createOrderOutput = new CreateOrderOutput(
                input.SenderId,
                input.RecipientName,
                input.RecipientSurname,
                input.RecipientPhoneNumber,
                Parcel,
                input.Status
                );

            _outputHandler.Standard(createOrderOutput);
        }
예제 #22
0
        private void BuildOutput(Guid id)
        {
            var output = new CreateUserOutput(id);

            _outputPort.Standard(output);
        }
예제 #23
0
        private void BuildOutput(IUser user)
        {
            var output = new UpdateUserOutput(user);

            _outputPort.Standard(output);
        }
        private void BuildOutput(IAccount account)
        {
            var output = new GetAccountDetailsOutput(account);

            _outputPort.Standard(output);
        }
예제 #25
0
        public void BuildOutput(ICustomer customer, IAccount account)
        {
            var output = new RegisterOutput(customer, account);

            _outputPort.Standard(output);
        }
예제 #26
0
        private void BuildOutput(ICustomer customer, List <Boundaries.GetCustomerDetails.Account> accounts)
        {
            var output = new GetCustomerDetailsOutput(customer, accounts);

            _outputHandler.Standard(output);
        }
예제 #27
0
        /// <inheritdoc/>
        public async Task Execute(ListSpacesInput input)
        {
            SpacesCollection spaces = await _spaceService.ListSpaces();

            _outputPort.Standard(new ListSpacesOutput(spaces));
        }
예제 #28
0
        private void BuildOutput(IAccount account)
        {
            var closeAccountOutput = new CloseAccountOutput(account);

            _outputPort.Standard(closeAccountOutput);
        }
예제 #29
0
        private void BuildOutput(IUser user)
        {
            var output = new GetUserDetailsOutput(user);

            _outputPort.Standard(output);
        }