public void Add(StockLevelModel stockLevel)
        {
            NHibernateUnitOfWork unitOfWork = (NHibernateUnitOfWork)UnitOfWork.Start();
            IRepository <StockLevelModel, int> stockLevelRepository = new NHibernateRepository <StockLevelModel, int>(unitOfWork);

            stockLevelRepository.Add(stockLevel);
            unitOfWork.SaveChanges();
            unitOfWork.Dispose();
        }
Пример #2
0
        public void GetNumberOfProductInCategory()
        {
            RequestModel model = new RequestModel
            {
                Id = 1
            };

            StockLevelModel stock = set.StockLevel.Report(model);

            Assert.AreEqual(stock.Sales.Count, 2);
        }
Пример #3
0
        public void GetStockInfoCategory_id_1()
        {
            RequestModel model = new RequestModel
            {
                Id = 1
            };
            StockLevelModel stock = set.StockLevel.Report(model);

            Assert.AreEqual(stock.Sales[0].ProductInput, 4);
            Assert.AreEqual(stock.Sales[0].ProductOutput, 2);
            Assert.AreEqual(stock.Sales[1].ProductInput, 3);
            Assert.AreEqual(stock.Sales[1].ProductOutput, 1);
        }
Пример #4
0
        public StockLevelModel Report(RequestModel request)
        {
            Category category = UnitOfWork.Categories.Get(request.Id);

            StockLevelModel result = new StockLevelModel()
            {
                CategoryId   = request.Id,
                CategoryName = category.Name
            };

            result.Sales = UnitOfWork.Products.Get().Where(x => x.Category.Id == category.Id).ToList()
                           .Select(x => Factory.Create(x.Id, x.Name, x.Unit, x.Stock)).ToList();

            return(result);
        }
Пример #5
0
        // Products By Category (parameter id is category id)
        public StockLevelModel Report(int id)
        {
            var Category = _unitOfWork.Categories.Get(id);

            if (Category == null)
            {
                throw new Exception("Category not found");
            }

            StockLevelModel result = new StockLevelModel(id, Category.Name);

            result.Products = _unitOfWork.Products.Get().Where(x => x.Category.Id == id).ToList()
                              .Select(x => _factory.Create(x.Id, x.Name, x.Stock)).ToList();

            return(result);
        }
Пример #6
0
        public StockLevelModel Report(int id)
        {
            StockLevelModel result   = new StockLevelModel();
            Category        category = UnitOfWork.Categories.Get(id);

            if (category == null)
            {
                result.Category = "Category does not exists!";
            }
            else
            {
                result.Category = category.Name;
                result.Products = category.Products.OrderBy(x => x.Name).Select(x => Factory.Create(x)).ToList();
            }
            return(result);
        }
        public void CreateDatabaseSchemaTest()
        {
            ProductModel    product     = new ProductModel();
            StockLevelModel stockLevel1 = new StockLevelModel();

            stockLevel1.Amount = 10;
            stockLevel1.Products.Add(product);
            product.ProductName = "可口可乐";
            product.UnitName    = "瓶子";
            product.StockLevels.Add(stockLevel1);
            productService.Add(product);
            stockLevelService.Add(stockLevel1);

            WarehouseModel warehouse = new WarehouseModel();

            warehouse.Address = "chengdu shi";
            warehouse.StockLevels.Add(stockLevel1);
            stockLevel1.Warehouses.Add(warehouse);

            warehouseService.Add(warehouse);

            IList <string> productNames = productService.GetAllProductNames();

            Console.WriteLine(productNames);

            DistributorModel distributor = new DistributorModel();

            distributor.Name    = "黄凯";
            distributor.Address = "贵州";

            distributorService.Add(distributor);

            IList <string> distributorNames = distributorService.GetAllDistributorNames();

            Console.WriteLine(distributorNames);
        }
Пример #8
0
 public void InitReport()
 {
     result = report.Report(categoryId);
 }