public async Task <IActionResult> Create([FromBody] SettingFieldCommand command) { var spec = SettingFieldSpecs.GetByNameSpec(command.Name); var isInvalid = await _settingFieldRepository.ExistsAsync(spec); if (isInvalid) { throw new CellException("Setting field name must be unique"); } var settingField = command.To <SettingField>(); _settingFieldRepository.Add(new SettingField( settingField.Name, settingField.Description, settingField.Code, settingField.AllowFilter, settingField.AllowSummary, settingField.Caption, settingField.DataType, settingField.OrdinalPosition, settingField.PlaceHolder, JsonConvert.SerializeObject(command.Settings), settingField.StorageType, settingField.TableId, settingField.TableName)); await _settingFieldRepository.CommitAsync(); return(Ok()); }
public async Task <IActionResult> Update([FromBody] SettingFieldCommand command) { var settingFieldResult = await _settingFieldRepository.GetByIdAsync(command.Id); var settingField = command.To <SettingField>(); settingFieldResult.Update( settingField.Name, settingField.Description, settingField.AllowFilter, settingField.AllowSummary, settingField.Caption, settingField.OrdinalPosition, settingField.PlaceHolder, JsonConvert.SerializeObject(command.Settings)); await _settingFieldRepository.CommitAsync(); return(Ok()); }