示例#1
0
        public override string this[string columnName]
        {
            get
            {
                string result = string.Empty;
                result = base[columnName];
                switch (columnName)
                {
                case "Number":
                    if (Number <= 0)
                    {
                        result = "Number must be greater than 0!";
                    }
                    break;

                case "ProductType":
                    if (ProductType.Contains("a"))
                    {
                        result = "Product type cannot contain 'a' letter";
                    }
                    break;

                case "ReleaseDate":
                    if (ReleaseDate == null)
                    {
                        result = "Release date must have a value";
                    }
                    break;
                }
                ;
                error = result;
                return(result);
            }
        }
        public ProductDetailViewModel(Product product, char?deli)
        {
            ProductID       = product.ProductID;
            ProductName     = product.ProductName;
            SupplierID      = product.SupplierID;
            CategoryID      = product.CategoryID;
            QuantityPerUnit = product.QuantityPerUnit;
            UnitPrice       = product.UnitPrice;
            UnitsInStock    = product.UnitsInStock;
            UnitsOnOrder    = product.UnitsOnOrder;
            ReorderLevel    = product.ReorderLevel;
            Discontinued    = product.Discontinued;
            ProductType     = product.ProductType;


            if (ProductType != null)
            {
                if (ProductType.Contains("FoodAndBeverageItems"))
                {
                    FoodNBeverageViewModel Foods = new FoodNBeverageViewModel(product, deli);
                    ProductDetail = Foods.convertToDictionary();
                }
                if (ProductType.Contains("GarmentItems"))
                {
                    GarmentViewModel Garment = new GarmentViewModel(product, deli);
                    ProductDetail = Garment.convertToDictionary();
                }
                if (ProductType.Contains("MaterialItems"))
                {
                    MaterialViewModel Material = new MaterialViewModel(product, deli);
                    ProductDetail = Material.convertToDictionary();
                }
                if (ProductType.Contains("TransportationServices"))
                {
                    TransportationServicesViewModel Transport = new TransportationServicesViewModel(product, deli);
                    ProductDetail = Transport.convertServiceToDictionary();
                }
            }
        }