示例#1
0
        public async Task <IActionResult> Search([FromBody] TopicSearchViewModel model)
        {
            try
            {
                var response = await _service.Search(User, model, ModelState);

                return(response.JsonResult());
            }
            catch (Exception error)
            {
                _logger.Error(error);
                return(StandardResponse.ForError().JsonResult());
            }
        }
示例#2
0
        public async Task <StandardResponse> Search(ClaimsPrincipal identity, TopicSearchViewModel model, ModelStateDictionary modelState)
        {
            if (!modelState.IsValid)
            {
                return(modelState.StandardError());
            }

            using (var db = new ServiceDb())
            {
                using (var user = await _userService.Become(db, identity))
                {
                    var result = await _topicService.FindTopics(db, user, model.Query, model.Offset, model.Limit);

                    return(StandardResponse.For(result));
                }
            }
        }
        public async Task <IActionResult> Search(string searchTerm, int page = GlobalConstants.DefaultPageNumber)
        {
            if (string.IsNullOrEmpty(searchTerm) || string.IsNullOrWhiteSpace(searchTerm))
            {
                return(this.Redirect("/"));
            }

            var serviceModel = this.topicsService.GetAllTopicsBySearch(searchTerm, page);

            var viewModel = new TopicSearchViewModel()
            {
                SearchTerm = searchTerm,
                Topics     = new TopicsListingViewModel()
                {
                    TotalTopicsCount = serviceModel.TotalTopicsCount,
                    CurrentPage      = page,
                    Topics           = serviceModel.Topics,
                    Categories       = await this.categoriesService.GetAllAsync <CategoryInfoViewModel>(),
                },
            };

            return(this.View(viewModel));
        }
示例#4
0
 public ActionResult Search(TopicSearchViewModel topicSearchViewModel)
 {
     return(RedirectToAction("Search", "Topic", new { name = topicSearchViewModel.Name, labels = topicSearchViewModel.Labels }));
 }