Exemple #1
0
        public static async Task <PurchaseTransactionId> CreateFullValidPurchaseTransaction()
        {
            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 Commands.CreateFull
            {
                Id = null,
                TransactionDate = DateTime.Now
            };

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

            command.StoreId = store.Id;

            // Get Product
            var prod = await ProductHelpers.CreateValidProduct();

            // Add one LineItem
            var newLineItem = new LineItemStripped
            {
                Booking                = Booking.Credit,
                Price                  = "1.23",
                CurrencyCode           = "EUR",
                CurrencySymbol         = "€",
                CurrencySymbolPosition = CurrencySymbolPosition.End,
                Notes                  = "New notes",
                ProductId              = prod.Id
            };

            command.LineItems = new List <LineItemStripped>
            {
                newLineItem
            };

            var transactionController = new PurchaseTransactionController(service);
            await transactionController.Post(command);

            return(command.Id);
        }
Exemple #2
0
        public async static Task <PurchaseTransactionId> CreateFullValidPurchaseTransaction()
        {
            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.CreateFull();

            command.Id = null;

            // Add PurchaseDate
            command.TransactionDate = DateTime.Now;

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

            command.StoreId = store.Id;

            // Add one LineItem
            var newLineItem = new LineItemStripped
            {
                Booking                = Booking.Credit,
                Price                  = 1.23m,
                CurrencyCode           = "EUR",
                CurrencySymbol         = "€",
                CurrencySymbolPosition = CurrencySymbolPosition.end,
                Notes                  = "New notes"
            };

            command.LineItems = new List <LineItemStripped>();
            command.LineItems.Add(newLineItem);

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

            return(command.Id);
        }