public async Task <IActionResult> Add([FromBody] NewClientRegulationModel model) { if (!ModelState.IsValid) { return(BadRequest(ErrorResponse.Create("Invalid model.", ModelState))); } var clientRegulation = Mapper.Map <ClientRegulation>(model); try { await _clientRegulationService.AddAsync(clientRegulation); } catch (ServiceException exception) { _log.Error(nameof(Add), exception, $"{nameof(model)}: {model.ToJson()}. IP: {HttpContext.GetIp()}"); return(BadRequest(ErrorResponse.Create(exception.Message))); } _log.Info(nameof(Add), $"Client regulation added. {nameof(model)}: {model.ToJson()}. IP: {HttpContext.GetIp()}", model.ClientId); return(NoContent()); }
/// <summary> /// Adds the client regulation. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='model'> /// The model what describe a client regulation. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <ErrorResponse> AddClientRegulationAsync(this IRegulationAPI operations, NewClientRegulationModel model = default(NewClientRegulationModel), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.AddClientRegulationWithHttpMessagesAsync(model, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Adds the client regulation. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='model'> /// The model what describe a client regulation. /// </param> public static ErrorResponse AddClientRegulation(this IRegulationAPI operations, NewClientRegulationModel model = default(NewClientRegulationModel)) { return(operations.AddClientRegulationAsync(model).GetAwaiter().GetResult()); }