Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public static async 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 Commands.CreateFull();

            command.Id = null;
            command.TransactionDate = DateTime.Now;

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

            command.StoreId = store.Id;

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

            // Add one LineItem
            command.LineItems = new List <LineItemStripped>
            {
                new LineItemStripped
                {
                    Price                  = price.ToString(CultureInfo.InvariantCulture),
                    CurrencyCode           = "EUR",
                    CurrencySymbol         = "€",
                    CurrencySymbolPosition = CurrencySymbolPosition.End,
                    Booking                = Booking.Credit,
                    Notes                  = lineItem?.Notes,
                    ProductId              = prod.Id
                }
            };

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

            return(command.Id);
        }