public async Task <bool> SaveAsync(BackgroundTask task) { var document = new BackgroundTaskDocument(task); if (task.Id == 0) { await _repository.CreateAsync(document); task.Id = document.TaskId; return(true); } var existing = await _repository.RetrieveSingleOrDefaultAsync(x => x.TaskId == task.Id); if (existing == null) { await _repository.CreateAsync(document); _logger.Trace(() => "Creating new task with ID {Id} and handler '{Handler}'", document.Id, document.Handler); return(true); } document.Id = existing.Id; _logger.Trace(() => "Updating existing task with ID {Id} and handler '{Handler}'", document.Id, document.Handler); await _repository.UpdateAsync(existing.Id, document); return(true); }
public async Task <Domain.CustomerManagement.Customer> UpdateAsync(Domain.CustomerManagement.Customer existingDomainCustomer) { DataModels.CustomerManagement.Customer dataCustomer = _dataModelCustomerMapper.Map(existingDomainCustomer); var CustomerDocument = await _genericRepo.UpdateAsync(dataCustomer.Id, dataCustomer); Domain.CustomerManagement.Customer domainCustomer = _domainCustomerMapper.Map(CustomerDocument); return(domainCustomer); }
public async Task <Domain.InvoiceManagement.Invoice> UpdateAsync(Domain.InvoiceManagement.Invoice existingDomainInvoice) { DataModels.InvoiceManagement.Invoice dataInvoice = _dataModelInvoiceMapper.Map(existingDomainInvoice); var invoiceDocument = await _genericRepo.UpdateAsync(dataInvoice.Id, dataInvoice); Domain.InvoiceManagement.Invoice domainInvoice = _domainInvoiceMapper.Map(invoiceDocument); return(domainInvoice); }