Exemplo n.º 1
0
        public void Add(params SaleDTO[] models)
        {
            Locker.EnterWriteLock();
            try
            {
                foreach (var sale in models)
                {
                    Clients.AddClientToDatabase(sale.Client);
                    Clients.Save();
                    sale.Client.ID = Clients.GetId(sale.Client.Name, sale.Client.Surname);

                    Managers.AddManagerToDatabase(sale.Manager);
                    Managers.Save();
                    sale.Manager.ID = Managers.GetId(sale.Manager.Surname);

                    Products.AddProductToDatabase(sale.Product);
                    Products.Save();
                    sale.Product.ID = Products.GetId(sale.Product.Name);

                    Sales.Add(sale);
                    Sales.Save();
                }
            }
            finally
            {
                Locker.ExitWriteLock();
            }
        }