public async Task <IActionResult> Search(SearchSettingActionCommand command) { var spec = SettingActionSpecs.SearchByQuery(command.Query).And(SettingActionSpecs.SearchByTableId(command.TableId)); var queryable = _settingActionRepository.QueryAsync(spec, command.Sorts); var items = await queryable.Skip(command.Skip).Take(command.Take).ToListAsync(); return(Ok(new QueryResult <SettingActionCommand> { Count = queryable.Count(), Items = items.To <List <SettingActionCommand> >() })); }
public async Task <IActionResult> Create([FromBody] SettingActionCommand command) { var spec = SettingActionSpecs.GetByNameSpec(command.Name); var isInvalid = await _settingActionRepository.ExistsAsync(spec); if (isInvalid) { throw new CellException("Setting action name must be unique"); } _settingActionRepository.Add(new SettingAction( command.Code, command.Name, command.Description, command.ContainerType, JsonConvert.SerializeObject(command.Settings), command.TableId, command.TableName)); await _settingActionRepository.CommitAsync(); return(Ok()); }