Esempio n. 1
0
        public async Task <IActionResult> Update([FromBody] WelcomeRegulationRuleModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ErrorResponse.Create("Invalid model.", ModelState)));
            }

            var regulationRule = Mapper.Map <WelcomeRegulationRule>(model);

            try
            {
                await _welcomeRegulationRuleService.UpdateAsync(regulationRule);
            }
            catch (ServiceException exception)
            {
                _log.Error(nameof(Update), exception, $"{nameof(model)}: {model.ToJson()}. IP: {HttpContext.GetIp()}");

                return(BadRequest(ErrorResponse.Create(exception.Message)));
            }

            _log.Info(nameof(Update), $"Welcome regulation rule updated. {nameof(model)}: {model.ToJson()}. IP: {HttpContext.GetIp()}",
                      model.RegulationId);

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Get(string welcomeRegulationRuleId)
        {
            IWelcomeRegulationRule regulationRule;

            try
            {
                regulationRule = await _welcomeRegulationRuleService.GetAsync(welcomeRegulationRuleId);
            }
            catch (ServiceException exception)
            {
                _log.Error(nameof(Get), exception, $"{nameof(welcomeRegulationRuleId)}: {welcomeRegulationRuleId}. IP: {HttpContext.GetIp()}");

                return(BadRequest(ErrorResponse.Create(exception.Message)));
            }

            WelcomeRegulationRuleModel model =
                Mapper.Map <IWelcomeRegulationRule, WelcomeRegulationRuleModel>(regulationRule);

            return(Ok(model));
        }
 /// <summary>
 /// Updates welcome regulation rule.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// The model what describe a welcome regulation rule.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ErrorResponse> UpdateWelcomeRegulationRuleAsync(this IRegulationAPI operations, WelcomeRegulationRuleModel model = default(WelcomeRegulationRuleModel), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateWelcomeRegulationRuleWithHttpMessagesAsync(model, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Updates welcome regulation rule.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='model'>
 /// The model what describe a welcome regulation rule.
 /// </param>
 public static ErrorResponse UpdateWelcomeRegulationRule(this IRegulationAPI operations, WelcomeRegulationRuleModel model = default(WelcomeRegulationRuleModel))
 {
     return(operations.UpdateWelcomeRegulationRuleAsync(model).GetAwaiter().GetResult());
 }