protected override async Task <JobResult> ProcessQueueEntryAsync(QueueEntryContext <AddressTransactedWorkItem> context) { string address = context.QueueEntry.Value.Address; if (string.IsNullOrEmpty(address)) { return(JobResult.SuccessWithMessage("Address was empty (maybe a contract deployment?), skipping")); } if (await _addressCache.ExistsAsync(address).AnyContext()) { return(JobResult.SuccessWithMessage($"Address {address} exists in cache, skipping")); } try { if (!await _addressRepository.AddressExists(address).AnyContext()) { await _addressRepository.UpsertAddress(new CinderAddress { Hash = address, ForceRefresh = true }).AnyContext(); } await _addressCache.AddAsync(address, string.Empty).AnyContext(); } catch (Exception e) { return(JobResult.FromException(e)); } return(JobResult.Success); }
public IActionResult CreateAddress([FromBody] AddressDto addressDto) { if (addressDto == null) { return(BadRequest(ModelState)); } if (_addressRepository.AddressExists(addressDto.Nome)) { ModelState.AddModelError("", "Address Exists!"); return(StatusCode(404, ModelState)); } var obj = _mapper.Map <Address>(addressDto); if (!_addressRepository.CreateAddress(obj)) { ModelState.AddModelError("", $"Something went wrong when saving the record {obj.Nome}"); return(StatusCode(500, ModelState)); } return(CreatedAtRoute("GetAddress", new { id = obj.Id }, obj)); }