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> AddAsync(Domain.CustomerManagement.Customer newDomainCustomer)
        {
            DataModels.CustomerManagement.Customer dataCustomer = _dataModelCustomerMapper.Map(newDomainCustomer);

            dataCustomer = await _genericRepo.CreateAsync(dataCustomer);

            Domain.CustomerManagement.Customer domainCustomer = _domainCustomerMapper.Map(dataCustomer);

            return(domainCustomer);
        }
Exemple #3
0
        public async Task <Domain.InvoiceManagement.Invoice> AddAsync(Domain.InvoiceManagement.Invoice newDomainInvoice)
        {
            DataModels.InvoiceManagement.Invoice dataInvoice = _dataModelInvoiceMapper.Map(newDomainInvoice);

            dataInvoice = await _genericRepo.CreateAsync(dataInvoice);

            Domain.InvoiceManagement.Invoice domainInvoice = _domainInvoiceMapper.Map(dataInvoice);

            return(domainInvoice);
        }
Exemple #4
0
 public async Task CreateAsync(ApplicationVersion model)
 {
     var document = new ApplicationVersionDocument(model);
     await _repository.CreateAsync(document);
 }
Exemple #5
0
 public async Task CreateAsync(SchemaVersion model)
 {
     var document = new SchemaVersionDocument(model);
     await _repository.CreateAsync(document);
 }