Example #1
0
        private ObservableCollection <MyProduct> convertData(List <Dictionary <String, String> > data)
        {
            ObservableCollection <MyProduct> converted = new ObservableCollection <MyProduct>();

            foreach (Dictionary <String, String> currentProduct in data)
            {
                decimal   number = Decimal.Parse(currentProduct["StandardCost"]);
                decimal?  val    = Decimal.TryParse(currentProduct["Weight"], out var tempVal) ? tempVal : (decimal?)0;
                MyProduct p      = new MyProduct(Int32.Parse(currentProduct["ProductID"]), currentProduct["Name"], currentProduct["ProductNumber"], currentProduct["Color"], short.Parse(currentProduct["SafetyStockLevel"]), number, currentProduct["Size"], (decimal)val);
                converted.Add(p);
            }
            return(converted);
        }
Example #2
0
        public string updateProduct(MyProduct product)
        {
            string message = "";

            try
            {
                message  = dataContext.updateProduct(product.ProductID, product.Name, product.ProductNumber, product.Color, product.SafetyStockLevel, product.StandardCost, product.Size, product.Weight);
                products = convertData(dataContext.getAll());
            }
            catch (NullReferenceException)
            {
                return("There is not such product in database");
            }
            return(message);
        }