public async Task <ComponentsAutocompleteResponse> ComponentsAutocomplete(ComponentsAutocompleteRequest request) { ComponentsAutocompleteResponse response = new ComponentsAutocompleteResponse(); try { RefSqlPaging sqlPaging = new RefSqlPaging(0, 100); switch (request.ComponentType) { case EnumDefine.TemplateConfigComponentTypeEnum.Banner: { var banners = await _bannerService.SearchBanner(string.Empty, request.Tearm, 0, sqlPaging); response.Components = banners.Select(p => p.ToAutocompleteModel()).ToArray(); } break; case EnumDefine.TemplateConfigComponentTypeEnum.Menu: { } break; case EnumDefine.TemplateConfigComponentTypeEnum.ProductGroup: break; } } catch (Exception e) { response.SetFail(e); _logger.LogError(e, e.Message, request); } return(response); }
public async Task <IActionResult> SearchComponents([FromQuery] ComponentsAutocompleteRequest request) { try { ComponentsAutocompleteResponse response = new ComponentsAutocompleteResponse(); ValidationResult validate = ComponentsAutocompleteRequestValidate.ValidateModel(request); if (validate.IsValid) { response = await _templateConfigAppService.ComponentsAutocomplete(request); } else { response.SetFail(validate.Errors.Select(p => p.ToString())); } return(Json(response)); } catch (Exception e) { _logger.LogError(e, Common.Common.GetMethodName(), request); throw; } }