public async Task <IActionResult> Get(int id) { var res = await _assetPropertyService.GetById(id); var model = _outputConverter.Map <CreateAssetPropertyRequest>(res); return(Ok(model)); }
public async Task Process(Input input) { Order order = await orderReadOnlyRepository.Get(input.OrderId); TrackingOutput output = outputConverter.Map <TrackingOutput>(order); outputBoundary.Populate(output); }
public async System.Threading.Tasks.Task Execute() { var allTasks = await _taskRepository.GetAll(); var tasksDto = _outputConverter.Map <List <TaskDto> >(allTasks); _outputBoundary.Populate(tasksDto); }
public async Task Process(ListBooksInput input) { var books = bookReadOnlyRepository.Select(); var booksOutput = books.Select(book => outputConverter.Map <BookOutput>(book)); ListBooksOutput output = new ListBooksOutput(booksOutput); outputBoundary.Populate(output); }
public async Task Process(AddBasketInput input) { Customer customer = await customerReadOnlyRepository.Get(input.CustomerId); if (customer == null) { throw new CustomerNotFoundException($"The customer {input.CustomerId} does not exist or it was not processed yet."); } Basket basket = new Basket(customer.Id); await basketWriteOnlyRepository.Add(basket); CustomerOutput customerOutput = outputConverter.Map <CustomerOutput>(customer); BasketOutput basketOutput = outputConverter.Map <BasketOutput>(basket); AddBasketOutput output = new AddBasketOutput(customerOutput, basketOutput); outputBoundary.Populate(output); }
public async Task Process(RegisterInput message) { Customer customer = new Customer(message.PIN, message.Name); Account account = new Account(); account.Open(customer.Id, new Credit(account.Id, message.InitialAmount)); customer.Register(account.Id); var customerEvents = customer.GetEvents(); var accountEvents = account.GetEvents(); await bus.Publish(customerEvents); await bus.Publish(accountEvents); // // To ensure the Customer and Account are created in the database // we wait for the records be available in the following queries // with retry // bool consumerReady = await RetryGet(async() => await customerReadOnlyRepository.Get(customer.Id)) && await RetryGet(async() => await accountReadOnlyRepository.Get(account.Id)); if (!consumerReady) { customer = null; account = null; // // TODO: Throw exception, monitor the inconsistencies and fail fast. // } CustomerOutput customerOutput = responseConverter.Map <CustomerOutput>(customer); AccountOutput accountOutput = responseConverter.Map <AccountOutput>(account); RegisterOutput output = new RegisterOutput(customerOutput, accountOutput); outputBoundary.Populate(output); }
public void Populate(PagedResult <AssetProperty> output, IOutputConverter outputConverter) { if (output == null) { ViewModel = new NoContentResult(); return; } var properties = outputConverter.Map <List <AssetProperties> >(output.Results); ViewModel = new ObjectResult(properties.GetPagedResult(output.PageSize, output.CurrentPage, output.RowCount)); }
public async Task Process(RegisterInput input) { Customer customer = new Customer(input.PIN, input.Name); Account account = new Account(customer.Id); Credit credit = new Credit(account.Id, input.InitialAmount); account.Deposit(credit); customer.Register(account.Id); await customerWriteOnlyRepository.Add(customer); await accountWriteOnlyRepository.Add(account, credit); CustomerOutput customerOutput = outputConverter.Map <CustomerOutput>(customer); AccountOutput accountOutput = outputConverter.Map <AccountOutput>(account); RegisterOutput output = new RegisterOutput(customerOutput, accountOutput); outputBoundary.Populate(output); }
public async Task Process(RegisterInput input) { Customer customer = new Customer(input.PIN, input.Name); await customerWriteOnlyRepository.Add(customer); CustomerOutput customerOutput = outputConverter.Map <CustomerOutput>(customer); RegisterOutput output = new RegisterOutput(customerOutput); outputBoundary.Populate(output); }
public async Task Process(CloseInput input) { Account account = await accountReadOnlyRepository.Get(input.AccountId); account.Close(); await accountWriteOnlyRepository.Delete(account); CloseOutput output = outputConverter.Map <CloseOutput>(account); this.outputBoundary.Populate(output); }
public async Task Process(GetCustomerDetailsInput input) { // // TODO: The following queries could be simplified // Customer customer = await customerReadOnlyRepository.Get(input.CustomerId); if (customer == null) { throw new CustomerNotFoundException($"The customer {input.CustomerId} does not exists or is not processed yet."); } List <AccountOutput> accounts = new List <AccountOutput>(); foreach (var accountId in customer.Accounts) { Account account = await accountReadOnlyRepository.Get(accountId); // // TODO: The "Accout closed state" is not propagating to the Customer Aggregate // if (account != null) { AccountOutput accountOutput = outputConverter.Map <AccountOutput>(account); accounts.Add(accountOutput); } } CustomerOutput output = outputConverter.Map <CustomerOutput>(customer); output = new CustomerOutput( customer.Id, customer.PIN.Text, customer.Name.Text, accounts); outputBoundary.Populate(output); }
public async Task Process(GetAccountDetailsInput input) { Account account = await accountReadOnlyRepository.Get(input.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {input.AccountId} does not exists or is already closed."); } AccountOutput output = outputConverter.Map <AccountOutput>(account); outputBoundary.Populate(output); }
public void Populate(List <TaskDto> response) { Output = response; if (Output == null) { ViewModel = new NoContentResult(); return; } var taskListModel = _outputConverter.Map <List <TaskDto> >(Output); ViewModel = new OkObjectResult(taskListModel); }
public async Task Process(GetBasketDetailsInput input) { var basket = await basketReadOnlyRepository.Get(input.BasketId); if (basket == null) { outputBoundary.Populate(null); return; } BasketOutput output = outputConverter.Map <BasketOutput>(basket); outputBoundary.Populate(output); }
public async Task Process(CheckoutInput input) { Customer customer = await customerReadOnlyRepository.Get(input.CustomerId); if (customer == null) { throw new CustomerNotFoundException($"The customer {input.CustomerId} does not exist or it was not processed yet."); } Basket basket = await basketReadOnlyRepository.Get(input.BasketId); if (basket == null) { throw new BasketNotFoundException($"The basket {input.BasketId} does not exist or it was already deleted."); } CustomerOutput customerOutput = outputConverter.Map <CustomerOutput>(customer); BasketOutput basketOutput = outputConverter.Map <BasketOutput>(basket); CheckoutOutput output = new CheckoutOutput(customerOutput, basketOutput, input.OrderDate, basket.GetTotalPrice().Value); outputBoundary.Populate(output); }
public async Task <IActionResult> Get([FromHeader] GridRequest request) { var data = await _userService.GetAll(request); if (data == null) { return(new BadRequestResult()); } var users = data.Results != null?_outputConverter.Map <List <UserListModel> >(data.Results) : null; var result = users.GetPagedResult(data.PageSize, data.CurrentPage, data.RowCount); return(Ok(result)); }
public async Task Process(DeleteInput input) { Basket basket = await basketReadOnlyRepository.Get(input.BasketId); if (basket == null) { throw new BasketNotFoundException($"The basket {input.BasketId} does not exist or it was already deleted."); } await basketWriteOnlyRepository.Delete(basket); DeleteOutput output = outputConverter.Map <DeleteOutput>(basket); this.outputBoundary.Populate(output); }
public async Task Process(CloseInput input) { Account account = await accountReadOnlyRepository.Get(input.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {input.AccountId} does not exists or is already closed."); } account.Close(); var domainEvents = account.GetEvents(); await bus.Publish(domainEvents); CloseOutput response = responseConverter.Map <CloseOutput>(account); this.outputBoundary.Populate(response); }
public async Task Process(DepositInput input) { Account account = await accountReadOnlyRepository.Get(input.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {input.AccountId} does not exists or is already closed."); } Credit credit = new Credit(account.Id, input.Amount); account.Deposit(credit); await accountWriteOnlyRepository.Update(account, credit); TransactionOutput transactionResponse = outputConverter.Map <TransactionOutput>(credit); DepositOutput output = new DepositOutput(transactionResponse, account.GetCurrentBalance().Value); outputBoundary.Populate(output); }
public async Task Process(CreateBookInput input) { Book book = bookReadOnlyRepository.Select(input.Isbn); if (book != null) { throw new BookAlreadyExistsException($"The book {input.Isbn} already exists."); } Book newNook = new Book( input.BookName, input.Isbn, input.Author, input.Price); bookWriteOnlyRepository.Insert(newNook); var output = outputConverter.Map <BookOutput>(newNook); outputBoundary.Populate(output); }
public async Task Process(WithdrawInput input) { Account account = await accountReadOnlyRepository.Get(input.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {input.AccountId} does not exists or is already closed."); } Debit debit = new Debit(account.Id, input.Amount); account.Withdraw(debit); var domainEvents = account.GetEvents(); await bus.Publish(domainEvents); TransactionOutput transactionOutput = responseConverter.Map <TransactionOutput>(debit); WithdrawOutput output = new WithdrawOutput(transactionOutput, account.GetCurrentBalance().Value); outputBoundary.Populate(output); }
public void Process(Input input) { HexagonalTemplate order = new HexagonalTemplate( input.Name, input.UseCases, input.UserInterface, input.DataAccess, input.Tips, input.SkipRestore); bus.Publish(order); trackingService.OrderReceived( order.Id, order.Name.Text, order.CommandLines); OrderOutput generateOutput = outputConverter.Map <OrderOutput>(order); outputBoundary.Populate(generateOutput); }
public async Task Process(RemoveBookInput input) { Book book = await bookReadOnlyRepository.Get(input.BookId); if (book == null) { throw new BookNotFoundException($"The book {input.BookId} does not exist."); } Basket basket = (input.BasketId != null)? await basketReadOnlyRepository.Get(input.BasketId):new Basket(); Removal removal = new Removal(book.Id); basket.RemoveBook(removal); await basketWriteOnlyRepository.Update(basket); OrderOutput orderResponse = outputConverter.Map <OrderOutput>(removal); RemoveBookOutput output = new RemoveBookOutput(orderResponse, basket.GetTotalPrice().Value); outputBoundary.Populate(output); }
public async Task Process(WithdrawInput input) { Account account = await accountReadOnlyRepository.Get(input.AccountId); if (account == null) { throw new AccountNotFoundException($"The account {input.AccountId} does not exists or is already closed."); } Debit debit = new Debit(new Amount(input.Amount)); account.Withdraw(debit); await accountWriteOnlyRepository.Update(account); TransactionOutput transactionOutput = outputConverter.Map <TransactionOutput>(debit); WithdrawOutput output = new WithdrawOutput( transactionOutput, account.GetCurrentBalance().Value ); outputBoundary.Populate(output); }