コード例 #1
0
        public ShopsServiceUnitTests()
        {
            var options = new DbContextOptionsBuilder <ShopsDbContext>()
                          .UseInMemoryDatabase("test_shops");
            var shopsContext = new ShopsDbContext(options.Options);

            _shopsService = new ShopsService(shopsContext);
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: ReklamaTM/reklama
        public ActionResult NewInCatalog()
        {
            var shopService = new ShopsService();
            //var news = _newSectionInCatalogRepository.Read();
            var news = shopService.GetNewCategories();

            return(View(news));
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: ReklamaTM/reklama
        public ActionResult PopularSectionsInCatalog()
        {
            var shopService = new ShopsService();
            //var popularSections1 = _popularSectionCatalogRepository.Read().ToList();
            var popularSections = shopService.GetPopularCategories().ToList();

            return(View(popularSections));
        }
コード例 #4
0
ファイル: BuyProducts.cs プロジェクト: bezlla/RtuItLab
        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
            });
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: ReklamaTM/reklama
        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));
            }
        }
コード例 #6
0
 public async Task Consume(ConsumeContext <AddProductsByFactoryRequest> context)
 {
     await ShopsService.AddProductsByFactory(context.Message.Products);
 }
コード例 #7
0
ファイル: GetAllShops.cs プロジェクト: bezlla/RtuItLab
 public async Task Consume(ConsumeContext <GetAllShopsRequest> context)
 {
     var order = ShopsService.GetAllShops();
     await context.RespondAsync(order);
 }
コード例 #8
0
ファイル: GetProductsByShop.cs プロジェクト: bezlla/RtuItLab
        public async Task Consume(ConsumeContext <GetProductsRequest> context)
        {
            var order = await ShopsService.GetProductsByShop(context.Message.ShopId);

            await context.RespondAsync(order);
        }
コード例 #9
0
 public ShopManagerService()
 {
     _productsServ = new ProductsService();
     _shopsServ    = new ShopsService();
     _typesServ    = new ProductTypesService();
 }