public void Update(string csv) { var lines = new StreamReader(csv).ReadToEnd().Replace("\r", "").Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); for (var i = 1; i < lines.Length; i++) { var values = lines[i].Split(","); _product.AddProduct(new Product() { ProductName = values[0], BarCode = Convert.ToString(values[1]), CategoriesId = _csvHelper.Categoryauto(values[2]), BrandId = _csvHelper.BrandId(values[8]), WholesalePrice = _csvHelper.WholesaleID(Convert.ToInt32(values[9]), Convert.ToInt32(values[10])), StockLevel = Convert.ToInt32(Convert.ToDouble(values[10]) * Convert.ToDouble(values[16]) * Convert.ToDouble(values[17])), OrderLevel = Convert.ToDouble(values[10]) * Convert.ToDouble(values[16]) * Convert.ToDouble(values[17]), Price = Convert.ToDecimal(values[12]), MinimumWholesaleOrder = Convert.ToDouble(values[13]) * Convert.ToDouble(values[14]), }); for (var j = 2; j < 7; j++) { _csvHelper.Categoryauto(values[j], values[j + 1]); } } }