Ejemplo n.º 1
0
        public async static Task <Store> CreateValidStore()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new StoreService(repository, unitOfWork);

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

            command.Name = "New store";
            command.Id   = null;

            // Create Store
            var storeController = new StoreController(service);
            var storeId         = await storeController.Post(command);

            // Update store name
            var updateCommand = new store.Commands.SetStoreName();

            updateCommand.Id   = storeId.Value.Id;
            updateCommand.Name = "Test market";

            await storeController.Put(updateCommand);

            return(await repository.GetStoreFullAsync(command.Id));
        }
Ejemplo n.º 2
0
        public static async Task <Store> CreateValidStore()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new StoreService(repository, unitOfWork);

            var newLocation = await LocationHelpers.CreateValidLocation();

            var command = new store.Commands.Create
            {
                Name       = "New store",
                Id         = null,
                LocationId = newLocation.Id
            };


            // Create Store
            var storeController = new StoreController(service);
            await storeController.Post(command);


            return(await repository.GetAsync(command.Id));
        }
Ejemplo n.º 3
0
        public static async Task <Product> CreateValidProduct()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new ProductRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new ProductService(repository, unitOfWork);

            var newBrand = await BrandHelpers.CreateValidBrand();

            var command = new product.Commands.Create
            {
                Name    = "New product",
                Id      = null,
                BrandId = newBrand.Id
            };


            // Create product
            var productController = new ProductController(service);
            await productController.Post(command);


            return(await repository.GetProductFullAsync(command.Id));
        }
Ejemplo n.º 4
0
        public async static Task <bool> CheckIfStoreExists(StoreId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);

            return(await repository.ExistsAsync(id));
        }
Ejemplo n.º 5
0
        public async static Task <PurchaseTransaction> ReloadPurchaseTransaction(PurchaseTransactionId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new PurchaseTransactionRepository(context);

            return(await repository.GetPurchaseTransactionFullAsync(id));
        }
Ejemplo n.º 6
0
        public static async Task UpdateCityName(CityId id, string name)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new CityRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new CityService(repository, unitOfWork);
            var cityController   = new CityController(service);

            var updateCommand = new Commands.SetCityName {
                Id = id, Name = name
            };

            await cityController.Put(updateCommand);
        }
Ejemplo n.º 7
0
        public async static Task RemoveStore(StoreId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new StoreService(repository, unitOfWork);
            var storeController  = new StoreController(service);

            var updateCommand = new store.Commands.DeleteStore();

            updateCommand.Id = id;

            await storeController.DeleteStore(updateCommand);
        }
Ejemplo n.º 8
0
        public static async Task <dynamic> CreateInvalidBrand()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new BrandRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new BrandService(repository, unitOfWork);

            var command = new Commands.Create {
                Id = null
            };

            var brandController = new BrandController(service);

            return(await brandController.Post(command));
        }
Ejemplo n.º 9
0
        public static async Task RemoveProduct(ProductId id)
        {
            var connectionString  = ConnectivityService.GetConnectionString("TEMP");
            var context           = new SplurgeStopDbContext(connectionString);
            var repository        = new ProductRepository(context);
            var unitOfWork        = new EfCoreUnitOfWork(context);
            var service           = new ProductService(repository, unitOfWork);
            var productController = new ProductController(service);

            var updateCommand = new product.Commands.DeleteProduct
            {
                Id = id
            };

            await productController.DeleteProduct(updateCommand);
        }
Ejemplo n.º 10
0
        public static async Task RemoveCountry(CountryId id)
        {
            var connectionString  = ConnectivityService.GetConnectionString("TEMP");
            var context           = new SplurgeStopDbContext(connectionString);
            var repository        = new CountryRepository(context);
            var unitOfWork        = new EfCoreUnitOfWork(context);
            var service           = new CountryService(repository, unitOfWork);
            var countryController = new CountryController(service);

            var updateCommand = new Commands.DeleteCountry
            {
                Id = id
            };

            await countryController.DeleteCountry(updateCommand);
        }
Ejemplo n.º 11
0
        public async static Task UpdateStore(PurchaseTransactionId id, Store store)
        {
            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.SetPurchaseTransactionStore();

            updateCommand.Id      = id;
            updateCommand.StoreId = store.Id;

            await transactionController.Put(updateCommand);
        }
Ejemplo n.º 12
0
        public async static Task <dynamic> CreateInvalidStore()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new StoreService(repository, unitOfWork);

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

            command.Id = null;

            // Create Store
            var storeController = new StoreController(service);

            return(await storeController.Post(command));
        }
Ejemplo n.º 13
0
        public static async Task <Brand> CreateValidBrand()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new BrandRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new BrandService(repository, unitOfWork);

            var command = new Commands.Create {
                Name = "Levi's", Id = null
            };

            var brandController = new BrandController(service);
            var brand           = await brandController.Post(command);

            return(await repository.GetAsync(brand.Value.Id));
        }
Ejemplo n.º 14
0
        public static async Task UpdateProductType(ProductId id, ProductType productType)
        {
            var connectionString  = ConnectivityService.GetConnectionString("TEMP");
            var context           = new SplurgeStopDbContext(connectionString);
            var repository        = new ProductRepository(context);
            var unitOfWork        = new EfCoreUnitOfWork(context);
            var service           = new ProductService(repository, unitOfWork);
            var productController = new ProductController(service);

            var updateCommand = new product.Commands.ChangeProductType
            {
                Id            = id,
                ProductTypeId = productType.Id
            };

            await productController.Put(updateCommand);
        }
Ejemplo n.º 15
0
        public static async Task UpdateSizeAmount(size.SizeId id, string amount)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new SizeRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new size.SizeService(repository, unitOfWork);
            var sizeController   = new SizeController(service);

            var updateCommand = new size.Commands.SetSizeAmount
            {
                Id     = id,
                Amount = amount
            };

            await sizeController.Put(updateCommand);
        }
Ejemplo n.º 16
0
        public static async Task UpdateStoreLocation(StoreId id, Location location)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new StoreRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new StoreService(repository, unitOfWork);
            var storeController  = new StoreController(service);

            var updateCommand = new store.Commands.ChangeLocation
            {
                Id       = id,
                Location = location
            };

            await storeController.Put(updateCommand);
        }
Ejemplo n.º 17
0
        public static async Task UpdatePurchaseDate(PurchaseTransactionId id, DateTime date)
        {
            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 Commands.SetPurchaseTransactionDate
            {
                Id = id,
                TransactionDate = date
            };

            await transactionController.Put(updateCommand);
        }
Ejemplo n.º 18
0
        public static async Task UpdateLocationCountry(LocationId id, Country country)
        {
            var connectionString   = ConnectivityService.GetConnectionString("TEMP");
            var context            = new SplurgeStopDbContext(connectionString);
            var repository         = new LocationRepository(context);
            var unitOfWork         = new EfCoreUnitOfWork(context);
            var service            = new LocationService(repository, unitOfWork);
            var locationController = new LocationController(service);

            var updateCommand = new Commands.ChangeCountry
            {
                Id      = id,
                Country = country
            };

            await locationController.Put(updateCommand);
        }
Ejemplo n.º 19
0
        public static async Task UpdateProductName(ProductId id, string name, BrandId brandId)
        {
            var connectionString  = ConnectivityService.GetConnectionString("TEMP");
            var context           = new SplurgeStopDbContext(connectionString);
            var repository        = new ProductRepository(context);
            var unitOfWork        = new EfCoreUnitOfWork(context);
            var service           = new ProductService(repository, unitOfWork);
            var productController = new ProductController(service);

            var updateCommand = new product.Commands.UpdateProduct
            {
                Id      = id,
                Name    = name,
                BrandId = brandId
            };

            await productController.Put(updateCommand);
        }
Ejemplo n.º 20
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.º 21
0
        public static async Task <dynamic> CreateInvalidLocation(string invalidProp)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new LocationRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new LocationService(repository, unitOfWork);

            var command = new Commands.Create
            {
                Id                             = null,
                CityId                         = invalidProp == "CityId" ? default : Guid.NewGuid(),
                                     CountryId = invalidProp == "CountryId" ? default : Guid.NewGuid()
            };

            var locationController = new LocationController(service);

            return(await locationController.Post(command));
        }
Ejemplo n.º 22
0
        public static async Task <Country> CreateValidCountry()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new CountryRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new CountryService(repository, unitOfWork);

            var command = new Commands.Create
            {
                Name = "Rapture",
                Id   = null
            };

            var countryController = new CountryController(service);
            var country           = await countryController.Post(command);

            return(await repository.GetAsync(country.Value.Id));
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
0
        public static async Task <ProductType> CreateValidProductType()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new ProductTypeRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new ProductTypeService(repository, unitOfWork);

            var command = new Commands.Create
            {
                Name = "trousers",
                Id   = null
            };

            var productTypeController = new ProductTypeController(service);
            var productType           = await productTypeController.Post(command);

            return(await repository.GetAsync(productType.Value.Id));
        }
Ejemplo n.º 25
0
        public static async Task <size.Size> CreateValidSize()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new SizeRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new size.SizeService(repository, unitOfWork);

            var command = new size.Commands.Create
            {
                Amount = "L",
                Id     = null
            };

            var sizeController = new SizeController(service);
            var size           = await sizeController.Post(command);

            return(await repository.GetAsync(size.Value.Id));
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        public static async Task <Location> CreateValidLocation()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new LocationRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new LocationService(repository, unitOfWork);

            var city = await CityHelpers.CreateValidCity();

            var country = await CountryHelpers.CreateValidCountry();

            var command = new Commands.Create {
                Id = null, CityId = city.Id, CountryId = country.Id
            };

            var locationController = new LocationController(service);
            var location           = await locationController.Post(command);

            return(await repository.GetAsync(location.Value.Id));
        }
Ejemplo n.º 28
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);
        }
Ejemplo n.º 29
0
        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);
        }
 public PurchaseTransactionRepository(SplurgeStopDbContext context)
 {
     this._context = context ?? throw new ArgumentNullException(nameof(context));
 }