public bool AddImport(string productId, long tin, int priceByUnit,
                              int ammount, bool IsStored, DateTime entryDate, DateTime departureDate)
        {
            Product product = new Product(productId);
            Client  client  = new Client(tin);

            IRepository <Import> repository = new ImportRepository();
            Import import = new Import(product, client, ammount, priceByUnit, entryDate, departureDate, IsStored);

            if (repository.Add(import))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        private static bool makeImportsTable()
        {
            string folder   = "Files";
            string fileName = "Imports.txt";

            string route = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, folder, fileName);

            try
            {
                StreamReader file = new StreamReader(route);
                string       line = file.ReadLine();

                List <Import> importList = new List <Import>();

                while (line != null)
                {
                    string[] values = line.Split('#');

                    Product product = new Product(values[0]);
                    Client  client  = new Client(Convert.ToInt64(values[1]));

                    Import import = new Import(product, client, Convert.ToInt32(values[2]), Convert.ToInt32(values[3]), Convert.ToDateTime(values[4]), Convert.ToDateTime(values[5]), Convert.ToBoolean(values[6]));
                    importList.Add(import);

                    line = file.ReadLine();
                }

                IRepository <Import> importRepository = new ImportRepository();

                foreach (var i in importList)
                {
                    importRepository.Add(i);
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }