Esempio n. 1
0
        private void FillUser()
        {
            IDProvider   id       = new IDProvider();
            string       filePath = @"Data/users.csv";
            StreamReader reader;

            if (File.Exists(filePath))
            {
                reader = new StreamReader(File.OpenRead(filePath));
                string header = reader.ReadLine();
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    line = StripHTML(line);
                    var  values = line.Split(',');
                    User u      = new User(id.Next(), values[1], values[2], values[3], values[5], Convert.ToInt32(values[4]));
                    users.Add(u);
                }
                reader.Close();
            }
            else
            {
                throw new FileNotFoundException("File not found");
            }
        }
Esempio n. 2
0
        private void FillProduct()
        {
            IDProvider   id       = new IDProvider();
            string       filePath = @"Data/products.csv";
            StreamReader reader;

            if (File.Exists(filePath))
            {
                reader = new StreamReader(File.OpenRead(filePath));
                string header = reader.ReadLine();
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    line = StripHTML(line);
                    var     values = line.Split(';');
                    Product p      = new Product(id.Next(), values[1], Convert.ToDecimal(values[2]), Convert.ToInt32(values[3]));
                    products.Add(p);
                }
                reader.Close();
            }
            else
            {
                throw new FileNotFoundException("File not found");
            }
        }