/// <summary> /// Конвертация в накладную закупок /// </summary> /// <param name="client">Накладная закупок БД</param> /// <returns>Накладная закупок</returns> public static InvoiceForPurchase Convert(InvoiceForPurchaseEnt invoiceForPurchase, bool logic = true) { if (invoiceForPurchase != null) { List <Product> productEnts = null; Employee employee = null; CompanyProvider companyProvider = null; if (logic == true) { companyProvider = Convert(invoiceForPurchase.CompanyProvider, false); employee = Convert(invoiceForPurchase.Employee, false); productEnts = new List <Product>(); foreach (var item in invoiceForPurchase.ProductEnts) { productEnts.Add(Convert(item, false)); } } InvoiceForPurchase invoiceForPurchaseEnt = new InvoiceForPurchase { Date = invoiceForPurchase.Date, Description = invoiceForPurchase.Description, CompanyProviderId = invoiceForPurchase.CompanyProviderId, EmployeeId = invoiceForPurchase.EmployeeId, Employee = employee, Id = invoiceForPurchase.Id, CompanyProvider = companyProvider, Archiving = invoiceForPurchase.Archiving, Products = productEnts }; return(invoiceForPurchaseEnt); } else { return(null); } }
/// <summary> /// Конвертация в накладную закупок БД /// </summary> /// <param name="client">Накладная закупок</param> /// <returns>Накладная закупок БД</returns> public static InvoiceForPurchaseEnt Convert(InvoiceForPurchase invoiceForPurchase) { if (invoiceForPurchase != null) { var x = Unit.InvoiceForPurchaseRepository.GetItem(invoiceForPurchase.Id); if (x != null) { return(x); } else { List <ProductEnt> productEnts = new List <ProductEnt>(); foreach (var item in invoiceForPurchase.Products) { productEnts.Add(Convert(item)); } InvoiceForPurchaseEnt invoiceForPurchaseEnt = new InvoiceForPurchaseEnt { CompanyProvider = Convert(invoiceForPurchase.CompanyProvider), Date = invoiceForPurchase.Date, Description = invoiceForPurchase.Description, Employee = Convert(invoiceForPurchase.Employee), Id = invoiceForPurchase.Id, CompanyProviderId = invoiceForPurchase.CompanyProviderId, EmployeeId = invoiceForPurchase.EmployeeId, ProductEnts = productEnts, Archiving = invoiceForPurchase.Archiving }; return(invoiceForPurchaseEnt); } } else { return(null); } }