public async Task <IActionResult> Search([FromBody] PerformSearchViewModel model) { try { var response = await _service.FindQuestions(User, model, ModelState); return(response.JsonResult()); } catch (Exception error) { _logger.Error(error); return(StandardResponse.ForError().JsonResult()); } }
public async Task <StandardResponse> FindQuestions(ClaimsPrincipal identity, PerformSearchViewModel model, ModelStateDictionary modelState) { if (!modelState.IsValid) { return(modelState.StandardError()); } using (var db = new ServiceDb()) { using (var user = await _userService.Become(db, identity, null)) { var result = await _searchService.SearchForQuestions(db, user, model.Query, model.Offset, model.Limit); return(StandardResponse.For(result)); } } }