Пример #1
0
        public async Task <IActionResult> Index(string key, int currentPage = 1, int itemsOnPage = 20)
        {
            int storageId = Int32.Parse(key);

            ViewData["StorageId"] = storageId;
            var model = await logic.GetAllDataModelAsync(storageId);

            // form pagenation model
            var pagenationModel = new Pagenation <ProductsDataModel>(model, itemsOnPage, currentPage);

            return(View(pagenationModel));
        }
Пример #2
0
        public async void RemoveRecipe_FromInitializedDbTable_RemovedRecipeNotFoundInDb()
        {
            // arrange
            var productCatalog = GetProductCatalog();
            var products       = GetProducts();

            fixture.db.Add(productCatalog);
            fixture.db.Product.AddRange(products);
            await fixture.db.SaveChangesAsync();

            var expected = new ProductsDataModel[]
            {
                new ProductsDataModel
                {
                    Id           = 44440,
                    Uid          = 44440,
                    Price        = 22.1M,
                    Quantity     = 5,
                    QuantityUnit = "mg.",
                    Name         = productCatalog.Name
                },
                new ProductsDataModel
                {
                    Id           = 44441,
                    Uid          = 44440,
                    Price        = 14.1M,
                    Quantity     = 6,
                    QuantityUnit = "mg.",
                    Name         = productCatalog.Name
                },
            };
            int storageId = 44440;

            // act
            var actual = await logic.GetAllDataModelAsync(storageId);

            // assert
            foreach (var expectedItem in expected)
            {
                Assert.Contains(actual, actualItem =>
                                expectedItem.Id == actualItem.Id &&
                                expectedItem.Name == actualItem.Name &&
                                expectedItem.Uid == actualItem.Uid &&
                                expectedItem.Price == actualItem.Price &&
                                expectedItem.Quantity == actualItem.Quantity &&
                                expectedItem.QuantityUnit == actualItem.QuantityUnit);
            }
        }