public async Task <IActionResult> Create([FromBody] SettingTableCommand command) { var spec = SettingTableSpecs.GetByNameSpec(command.Name); var isInvalid = await _settingTableRepository.ExistsAsync(spec); var isValidator = await EntityValidator.ValidateAsync(command.To <SettingTable>()); if (!isValidator.IsValid) { throw new CellException(isValidator); } if (isInvalid) { throw new CellException("Setting table name must be unique"); } _settingTableRepository.Add(new SettingTable( command.Name, command.Description, command.Code, command.BasedTable, JsonConvert.SerializeObject(command.Settings))); await _settingTableRepository.CommitAsync(); return(Ok()); }
public async Task <IActionResult> Update([FromBody] SettingTableCommand command) { var settingTable = await _settingTableRepository.GetByIdAsync(command.Id); settingTable.Update( command.Name, command.Description, command.Code, JsonConvert.SerializeObject(command.Settings)); await _settingTableRepository.CommitAsync(); return(Ok()); }