コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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));
                }
            }
        }