コード例 #1
0
ファイル: HelperMethods.cs プロジェクト: zxbe/SplurgeStop
        public async static Task <PurchaseTransactionId> CreateValidPurchaseTransaction(decimal price     = 1.00m,
                                                                                        LineItem lineItem = null)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new PurchaseTransactionRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new PurchaseTransactionService(repository, unitOfWork);

            var command = new transaction.Commands.Create();

            command.Id = null;

            // Create PurchaseTransaction
            var transactionController = new PurchaseTransactionController(service);
            var result = await transactionController.Post(command);

            // Add PurchaseDate
            await UpdatePurchaseDate(result.Value.Id, DateTime.Now);

            var purchaseTransaction = await repository.GetPurchaseTransactionFullAsync(result.Value.Id);

            // Add Store
            var store = await CreateValidStore();

            await UpdateStore(purchaseTransaction.Id, store);

            // Add one LineItem
            var updateLineItemCommand = new transaction.Commands.SetPurchaseTransactionLineItem();

            updateLineItemCommand.Id                     = purchaseTransaction.Id;
            updateLineItemCommand.Price                  = price;
            updateLineItemCommand.Currency               = "EUR";
            updateLineItemCommand.CurrencySymbol         = "€";
            updateLineItemCommand.Booking                = Booking.Credit;
            updateLineItemCommand.CurrencySymbolPosition = CurrencySymbolPosition.end;
            updateLineItemCommand.Notes                  = lineItem?.Notes;

            await transactionController.Put(updateLineItemCommand);

            return(command.Id);
        }
コード例 #2
0
ファイル: HelperMethods.cs プロジェクト: zxbe/SplurgeStop
        public async static Task UpdateLineItem(PurchaseTransactionId id, LineItem lineItem)
        {
            var connectionString      = ConnectivityService.GetConnectionString("TEMP");
            var context               = new SplurgeStopDbContext(connectionString);
            var repository            = new PurchaseTransactionRepository(context);
            var unitOfWork            = new EfCoreUnitOfWork(context);
            var service               = new PurchaseTransactionService(repository, unitOfWork);
            var transactionController = new PurchaseTransactionController(service);

            var updateCommand = new transaction.Commands.SetPurchaseTransactionLineItem();

            updateCommand.Id                     = id;
            updateCommand.LineItemId             = lineItem.Id;
            updateCommand.Price                  = lineItem.Price.Amount;
            updateCommand.Currency               = lineItem.Price.Currency.CurrencyCode;
            updateCommand.CurrencySymbol         = lineItem.Price.Currency.CurrencySymbol;
            updateCommand.Booking                = lineItem.Price.Booking;
            updateCommand.CurrencySymbolPosition = lineItem.Price.Currency.PositionRelativeToPrice;
            updateCommand.Notes                  = lineItem?.Notes;

            await transactionController.Put(updateCommand);
        }