public async Task CreateOutgoingDraftAsync(CreateOutgoingDraftModel model) { var customer = new PartyInfo { OriginalId = model.Customer.OriginalId, Name = model.Customer.Name, StreetName = Settings.Address, City = Settings.City, PostalCode = Settings.PostalCode, Country = Settings.Country, VatIndex = Settings.TaxId, NationalIdentificationNumber = Settings.TaxId }; var lineItems = model.LineItems.Select(l => new DraftLineItem { Code = l.Code, Description = l.Description, Quantity = l.Quantity, TotalPrice = l.TotalPrice, UnitPrice = l.UnitPrice, Vat = l.Vat }); var pricesByVat = model.PricesByVat.Select(p => new PriceByVat { TaxableAmount = p.TaxableAmount, TotalPrice = p.TotalPrice, VatAmount = p.VatAmount, VatRate = p.VatRate }); var nonTaxableItems = model.NonTaxableItems.Select(t => new NonTaxableItem { Amount = t.Amount, Description = t.Description }); switch (model.Type) { case Models.OutgoingDocumentTypes.OutgoingInvoice: await OutgoingInvoiceDraftCommands.CreateDraft( customer, model.Date, model.Currency, model.Amount, model.Taxes, model.TotalPrice, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, model.VatIncluded, lineItems, pricesByVat, nonTaxableItems); break; case Models.OutgoingDocumentTypes.OutgoingCreditNote: await OutgoingCreditNoteDraftCommands.CreateDraft( customer, model.Date, model.Currency, model.Amount, model.Taxes, model.TotalPrice, model.Description, model.PaymentTerms, model.PurchaseOrderNumber, model.VatIncluded, lineItems, pricesByVat, nonTaxableItems); break; } }