public void AddSale(SaleDto saleDto) { lock (_objLock) { var manager = new DAL.Models.Manager() { SecondName = saleDto.Manager }; var client = new DAL.Models.Client() { FullName = saleDto.Client }; var product = new DAL.Models.Product() { Name = saleDto.Product }; var managerId = _unitOfWork.Managers.GetId(manager); if (managerId == null) { _unitOfWork.Managers.Create(manager); _unitOfWork.Save(); managerId = _unitOfWork.Managers.GetId(manager); } var clientId = _unitOfWork.Clients.GetId(client); if (clientId == null) { _unitOfWork.Clients.Create(client); _unitOfWork.Save(); clientId = _unitOfWork.Clients.GetId(client); } var productId = _unitOfWork.Products.GetId(product); if (productId == null) { _unitOfWork.Products.Create(product); _unitOfWork.Save(); productId = _unitOfWork.Products.GetId(product); } var sale = new DAL.Models.SaleInfo() { ClientId = (int)clientId, ManagerId = (int)managerId, ProductId = (int)productId, Date = saleDto.Date, Amount = saleDto.Amount }; _unitOfWork.SalesInfo.Create(sale); _unitOfWork.Save(); } }
public void AddToDatabase(InfoList infoList) { lock (obj) { var newManager = new DAL.Models.Manager { ManagerName = infoList.ManagerName }; var manager = _managerRepository.GetEntity(newManager); if (manager == null) { _managerRepository.Add(newManager); _managerRepository.SaveChanges(); manager = _managerRepository.GetEntity(newManager); } var newClient = new DAL.Models.Client { ClientName = infoList.ClientName }; _clientRepository.Add(newClient); _clientRepository.SaveChanges(); var client = _clientRepository.GetEntity(newClient); var newProduct = new DAL.Models.Product { ProductName = infoList.ProductName, ProductCost = infoList.ProductCost }; _productRepository.Add(newProduct); _productRepository.SaveChanges(); var product = _productRepository.GetEntity(newProduct); var saleInfo = new DAL.Models.SaleInfo { SaleDate = infoList.SaleDate, ID_Manager = manager.ID_Manager, ID_Client = client.ID_Client, ID_Product = product.ID_Product }; _saleInfoRepository.Add(saleInfo); _saleInfoRepository.SaveChanges(); } }
public FileInformation(int id, string name, DateTime date, Manager manager) : this(name, date, manager) { this.Id = id; }
public FileInformation(string name, DateTime date, Manager manager) { this.Name = name; this.Date = date; this.Manager = manager; }
public void Update(Models.Manager item) { throw new NotImplementedException(); }
public void Remove(Models.Manager item) { var e = this.ToEntity(item); context.ManagerSet.Remove(e); }
public void Add(Models.Manager item) { var e = this.ToEntity(item); context.ManagerSet.Add(e); }