public async Task <IActionResult> Search(SearchSettingViewCommand command) { var spec = SettingViewSpecs.SearchByQuery(command.Query); var queryable = _settingViewRepository.QueryAsync(spec, command.Sorts); var items = await queryable.OrderBy(x => x.Name).Skip(command.Skip).Take(command.Take).ToListAsync(); return(Ok(new QueryResult <SettingViewCommand> { Count = queryable.Count(), Items = items.To <List <SettingViewCommand> >() })); }
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>())); }