示例#1
0
        public async Task <Versioned <AdminUserSettingsForClient> > SaveUserSetting(SaveUserSettingsArguments args)
        {
            await Initialize();

            // Retrieve the arguments
            var key   = args.Key;
            var value = args.Value;

            // Validation
            int maxKey   = 255;
            int maxValue = 2048;

            if (string.IsNullOrWhiteSpace(key))
            {
                // Key is required
                throw new ServiceException(_localizer[ErrorMessages.Error_Field0IsRequired, nameof(args.Key)]);
            }
            else if (key.Length > maxKey)
            {
                //
                throw new ServiceException(_localizer[ErrorMessages.Error_Field0LengthMaximumOf1, nameof(args.Key), maxKey]);
            }

            if (value != null && value.Length > maxValue)
            {
                throw new ServiceException(_localizer[ErrorMessages.Error_Field0LengthMaximumOf1, nameof(args.Value), maxValue]);
            }

            // Save and return
            await _repo.AdminUsers__SaveSettings(key, value);

            return(await UserSettingsForClient(cancellation : default));
示例#2
0
 public async Task <ActionResult <Versioned <AdminUserSettingsForClient> > > SaveUserSetting(SaveUserSettingsArguments args)
 {
     return(await ControllerUtilities.InvokeActionImpl(async() =>
     {
         var result = await _service.SaveUserSetting(args);
         return Ok(result);
     },
                                                       _logger));
 }
示例#3
0
        public async Task <ActionResult <Versioned <AdminUserSettingsForClient> > > SaveUserSetting(SaveUserSettingsArguments args)
        {
            var result = await _service.SaveUserSetting(args);

            return(Ok(result));
        }