public ShopsServiceUnitTests() { var options = new DbContextOptionsBuilder <ShopsDbContext>() .UseInMemoryDatabase("test_shops"); var shopsContext = new ShopsDbContext(options.Options); _shopsService = new ShopsService(shopsContext); }
public ActionResult NewInCatalog() { var shopService = new ShopsService(); //var news = _newSectionInCatalogRepository.Read(); var news = shopService.GetNewCategories(); return(View(news)); }
public ActionResult PopularSectionsInCatalog() { var shopService = new ShopsService(); //var popularSections1 = _popularSectionCatalogRepository.Read().ToList(); var popularSections = shopService.GetPopularCategories().ToList(); return(View(popularSections)); }
public async Task Consume(ConsumeContext <BuyProductsRequest> context) { var order = await ShopsService.BuyProducts(context.Message.ShopId, context.Message.Products); await context.RespondAsync(order); var transaction = await ShopsService.CreateTransaction(context.Message.ShopId, order); await ShopsService.AddReceipt(transaction.Receipt); var endpoint = await _busControl.GetSendEndpoint(_rabbitMqUrl); await endpoint.Send(new AddTransactionRequest { User = context.Message.User, Transaction = transaction }); }
public ActionResult PopularProducts() { var shopService = new ShopsService(); //var products = _popularProductRepository.Read().ToList(); var products = shopService.GetPopularProducts().ToList(); if (products.Count() <= 5) { return(View(products)); } else { var result = new List <Product>(); for (int i = 0; i < 5; i++) { int index = new Random().Next(products.Count()); result.Add(products[index]); products.RemoveAt(index); } return(View(result)); } }
public async Task Consume(ConsumeContext <AddProductsByFactoryRequest> context) { await ShopsService.AddProductsByFactory(context.Message.Products); }
public async Task Consume(ConsumeContext <GetAllShopsRequest> context) { var order = ShopsService.GetAllShops(); await context.RespondAsync(order); }
public async Task Consume(ConsumeContext <GetProductsRequest> context) { var order = await ShopsService.GetProductsByShop(context.Message.ShopId); await context.RespondAsync(order); }
public ShopManagerService() { _productsServ = new ProductsService(); _shopsServ = new ShopsService(); _typesServ = new ProductTypesService(); }