Example #1
0
        public async Task <IActionResult> Update([FromBody] SettingViewCommand command)
        {
            var settingView = await _settingViewRepository.GetByIdAsync(command.Id);

            settingView.Update(
                settingView.Name,
                settingView.Description,
                JsonConvert.SerializeObject(command.Settings));
            await _settingViewRepository.CommitAsync();

            return(Ok());
        }
Example #2
0
        public async Task <IActionResult> Create([FromBody] SettingViewCommand command)
        {
            var specs     = SettingViewSpecs.GetByNameSpec(command.Name);
            var isInvalid = await _settingViewRepository.ExistsAsync(specs);

            if (isInvalid)
            {
                throw new CellException("Setting view name must be unique");
            }
            var result = _settingViewRepository.Add(new SettingView(
                                                        command.Code,
                                                        command.Name,
                                                        command.Description,
                                                        command.TableId,
                                                        command.TableName,
                                                        JsonConvert.SerializeObject(command.Settings)));
            await _settingViewRepository.CommitAsync();

            return(Ok(result.To <SettingViewCommand>()));
        }