public async Task <BaseResponse> Change(LocaleStringResourceChangeRequest request) { BaseResponse response = new BaseResponse(); try { var command = request.ToCommand(); var result = await _localeStringResourceService.SendCommand(command); if (result.IsSucess) { response.SetSucess(); } else { response.SetFail(result.Message); } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public static LocaleStringResourceChangeCommand ToCommand(this LocaleStringResourceChangeRequest request) { if (request == null) { return(null); } return(new LocaleStringResourceChangeCommand() { LanguageId = request.LanguageId, ResourceName = request.ResourceName, ResourceValue = request.ResourceValue, Id = request.Id }); }
public async Task <IActionResult> Change([FromBody] LocaleStringResourceChangeRequest request) { try { BaseResponse response = new BaseResponse(); ValidationResult validate = LocaleStringResourceChangeRequestValidator.ValidateModel(request); if (validate.IsValid) { response = await _localeStringResourceAppService.Change(request); } else { response.SetFail(validate.Errors.Select(p => p.ToString())); } return(Json(response)); } catch (Exception e) { _logger.LogError(e, Common.Common.GetMethodName(), request); throw; } }