public virtual async Task AddUpdateBillingAddressAsync(Guid invoiceId, TblInvoiceBillingAddress address) { var invoice = await FindByIdAsync(invoiceId); if (invoice != null) { if (invoice.BillingAddress.Any()) { var records = (await _dbContext.InvoiceBillingAddress.Where(p => p.InvoiceId == invoiceId) .FromCacheAsync(CacheTags.Invoice)).ToList(); await _dbContext.InvoiceBillingAddress.Where(p => p.InvoiceId == invoiceId) .DeleteAsync(); records.ForEach(x => _eventPublisher.EntityDeleted(x)); } address.InvoiceId = invoiceId; _dbContext.InvoiceBillingAddress.Add(address); await _dbContext.SaveChangesAsync(); QueryCacheManager.ExpireTag(CacheTags.Invoice); _eventPublisher.EntityInserted(address); } }
public virtual InvoiceBillingAddressModel PrepareInvoiceBillingAddressModel(TblInvoiceBillingAddress address) { if (address == null) { return(new InvoiceBillingAddressModel()); } var result = address.Adapt <InvoiceBillingAddressModel>(); return(result); }