public async Task <IActionResult> AddAsync([FromBody] CreateLegalEntityModel model) { if (!ModelState.IsValid) { return(BadRequest(new ErrorResponse().AddErrors(ModelState))); } try { var legalEntity = Mapper.Map <LegalEntity>(model); await _legalEntityService.AddAsync(legalEntity); } catch (LegalEntityAlreadyExistsException exception) { await _log.WriteWarningAsync(nameof(LegalEntitiesController), nameof(AddAsync), model.ToJson(), exception.Message); return(BadRequest(ErrorResponse.Create(exception.Message))); } return(NoContent()); }
public Task AddLegalEntityAsync(CreateLegalEntityModel model, CancellationToken cancellationToken = default(CancellationToken)) => _runner.RunAsync(() => _legalEntitiesApi.AddAsync(model, cancellationToken));