public static Invoice MapFromEntity(data.Entities.Invoice entity) { if (entity == null) return null; var invoice = new Invoice() { InvoiceId = entity.InvoiceId, InvoiceNumber = entity.InvoiceNumber, Vendor = Vendor.MapFromEntity(entity.Vendor), InvoiceType = InvoiceType.MapFromEntity(entity.InvoiceType), InvoiceDate = entity.InvoiceDate, DatePaid = entity.DatePaid, Description = entity.Description }; invoice.AccountTotals = new List<InvoiceAccountTotal>(); if(entity.InvoiceAccounts != null) { foreach (var invoiceAccount in entity.InvoiceAccounts) { invoice.AccountTotals.Add(InvoiceAccountTotal.MapFromEntity(invoiceAccount)); } } //Tickets added from outside if the invoice entity due to the cpmplexit of the ticket entity return invoice; }
public InvoiceAccountTotal MapToCore() { var invoiceAcount = new InvoiceAccountTotal() { InvoiceAccountId = (InvoiceAccountId.HasValue) ? InvoiceAccountId.Value : 0, Account = new Account() { AccountId = this.AccountId }, Expense = this.Expense }; invoiceAcount.CityExpenses = new List <CityExpense>(); foreach (var account in CityAccounts) { if (account.CityAccountId > 0) { invoiceAcount.CityExpenses.Add(account.MapToCore(InvoiceAccountId)); } } return(invoiceAcount); }