public void Add(params SaleDto[] sales) { Locker.EnterWriteLock(); try { foreach (var sale in sales) { Customers.AddUniqueCustomerToDatabase(sale.Customer); Customers.Save(); sale.Customer.Id = Customers.GetId(sale.Customer.FirstName, sale.Customer.LastName); Managers.AddUniqueManagerToDatabase(sale.Manager); Managers.Save(); sale.Manager.Id = Managers.GetId(sale.Manager.LastName); Products.AddUniqueProductToDatabase(sale.Product); Products.Save(); sale.Product.Id = Products.GetId(sale.Product.Name); Sales.Add(sale); Sales.Save(); } } finally { Locker.ExitWriteLock(); } }
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(); } }