Beispiel #1
0
        public ProductsViewModel AddNewProduct(AddProductViewModel model)
        {
            var dalModel = new ProductDALModel();

            dalModel.ProductName     = model.Name;
            dalModel.QuantityPerUnit = model.QuantityPerUnit;

            _productStore.InsertNewProduct(dalModel);
            var dalProducts = _productStore.SelectAllProducts();

            return(ReturnListOfProducts(dalProducts));
        }
Beispiel #2
0
 public ProductListItemViewModel(ProductDALModel dalModel)
 {
     Name            = dalModel.ProductName;
     Id              = dalModel.ProductID;
     SupplierId      = dalModel.SupplierID;
     CategoryId      = dalModel.CategoryID;
     QuantityPerUnit = dalModel.QuantityPerUnit;
     UnitPrice       = dalModel.UnitPrice;
     UnitsInStock    = dalModel.UnitsInStock;
     UnitsOnOrder    = dalModel.UnitsOnOrder;
     ReorderLevel    = dalModel.ReorderLevel;
     Discontinued    = dalModel.Discontinued;
 }
        private ProductViewModel MapProductViewModel(ProductDALModel dalProduct)
        {
            var product = new ProductViewModel();

            product.ProductID       = dalProduct.ProductID;
            product.ProductName     = dalProduct.ProductName;
            product.SupplierID      = dalProduct.SupplierID;
            product.CategoryID      = dalProduct.CategoryID;
            product.QuantityPerUnit = dalProduct.QuantityPerUnit;
            product.UnitPrice       = dalProduct.UnitPrice;
            product.UnitsInStock    = dalProduct.UnitsInStock;
            product.UnitsOnOrder    = dalProduct.UnitsOnOrder;
            product.ReorderLevel    = dalProduct.ReorderLevel;
            product.Discontinued    = dalProduct.Discontinued;
            return(product);
        }
Beispiel #4
0
        public ProductsViewModel EditProduct(AProductViewModel model)
        {
            var dalModel = new ProductDALModel
            {
                ProductID       = model.ID,
                ProductName     = model.Name,
                SupplierID      = model.SupplierID,
                CategoryID      = model.CategoryID,
                QuantityPerUnit = model.QuantityPerUnit,
                UnitPrice       = model.UnitPrice,
                UnitsInStock    = model.UnitsInStock,
                UnitsOnOrder    = model.UnitsOnOrder
            };

            _productStore.UpdateProduct(dalModel);
            var dalProducts = _productStore.SelectAllProducts();

            return(ReturnListOfProducts(dalProducts));
        }
 public ProductListViewModel(ProductDALModel dalModel)
 {
     ProductId   = dalModel.ProductID;
     ProductName = dalModel.ProductName;
 }