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)); }
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)); }
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)); }
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)); }
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)); }
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); }
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); }
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)); }
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); }
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); }
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); }
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)); }
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)); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
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)); }
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); }
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)); }
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)); }
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); }
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)); }
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); }
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)); }