public async Task <IActionResult> GetCodes([FromRoute] Guid?domainId) { IActionResult result = null; try { if (result == null && (!domainId.HasValue || Guid.Empty.Equals(domainId.Value))) { result = BadRequest("Missing domain id parameter value"); } if (result == null) { using ILifetimeScope scope = _container.BeginLifetimeScope(); SettingsFactory settingsFactory = scope.Resolve <SettingsFactory>(); IItemFactory factory = scope.Resolve <IItemFactory>(); if (!(await VerifyDomainAccount(domainId.Value, settingsFactory, _settings.Value, scope.Resolve <IDomainService>()))) { result = StatusCode(StatusCodes.Status401Unauthorized); } else { result = Ok( await factory.GetCodes(settingsFactory.CreateCore(_settings.Value), domainId.Value) ); } } } catch (Exception ex) { using (ILifetimeScope scope = _container.BeginLifetimeScope()) { await LogException(ex, scope.Resolve <IExceptionService>(), scope.Resolve <SettingsFactory>(), _settings.Value); } result = StatusCode(StatusCodes.Status500InternalServerError); } return(result); }