public CategorySearchResponse Search(CategorySearchRequest request) { var response = new CategorySearchResponse(); Category result = null; en.Category categoryAlias = null; var queryOver = _session.QueryOver <en.Category>(() => categoryAlias); if (!string.IsNullOrWhiteSpace(request.Name)) { queryOver.WhereRestrictionOn(c => c.Name).IsInsensitiveLike(request.Name, nh.Criterion.MatchMode.Anywhere); } var rowCountQuery = queryOver.Clone() .ToRowCountQuery() .FutureValue <int>(); response.Items = queryOver .SelectList(list => list .Select(() => categoryAlias.Id).WithAlias(() => result.Id) .Select(() => categoryAlias.Name).WithAlias(() => result.Name) .Select(() => categoryAlias.LastUpdate).WithAlias(() => result.LastUpdate) ) .TransformUsing(Transformers.AliasToBean <Category>()) .List <Category>(); response.TotalItems = rowCountQuery.Value; return(response); }
async Task Submit() { DrivingLessonInsertRequest driving_lesson_insert_request = new DrivingLessonInsertRequest(); CategorySearchRequest categorySearchRequest = new CategorySearchRequest { Name = SelectedCandidate.category }; var categories = await categoryService.GetAll <List <Category> >(categorySearchRequest); var category = categories[0]; // Returns category of candidate search_request1.Username = APIService.Username; var instructors = await _instructorsService.GetAll <List <Instructor> >(search_request1); var instructor = instructors[0]; // Returns logged in instructor driving_lesson_insert_request.InstructorId = instructor.Id; driving_lesson_insert_request.CategoryId = category.Id; driving_lesson_insert_request.CandidateId = SelectedCandidate.Id; driving_lesson_insert_request.VehicleId = SelectedVehicle.Id; driving_lesson_insert_request.Mileage = Mileage; driving_lesson_insert_request.AverageFuelConsumption = AverageFuelConsumption; driving_lesson_insert_request.Damage = Damage; driving_lesson_insert_request.Date = Date; await _drivingLessonsService.Insert <DrivingLesson>(driving_lesson_insert_request); await Application.Current.MainPage.DisplayAlert("", "You have successfully added a lesson", "OK"); }
/// <summary> /// 分页获取 /// </summary> /// <param name="searchRequest">查询参数</param> /// <returns></returns> public async Task <JsonResultModel <CategoryInfo> > GetPageList(CategorySearchRequest searchRequest) { var exp = Expressionable.Create <CategoryInfo>() .OrIF(!string.IsNullOrEmpty(searchRequest.CategoryName), it => it.CategoryName.Contains(searchRequest.CategoryName)).ToExpression(); return(await base.GetPageList(searchRequest, exp)); }
private async void btnFilter_Click(object sender, EventArgs e) { CategorySearchRequest request = new CategorySearchRequest { Title = txtTitle.Text }; var categories = await _categoryService.Post <List <CategoryDto> >(request, "search"); categoriesGrid.DataSource = categories; }
public async Task <ActionResult> ListAjax(CategorySearchRequest search) { var categories = await _categoryService.GetPagedListAsync(search); var viewModel = new CategoryListViewModel { Categories = categories.Categories, SearchRequest = search }; return(PartialView("_ListAjax", viewModel)); }
public async Task <ResponseList <CategoryResponse> > Search(CategorySearchRequest request) { int skip = request.PageNumber * request.PageSize; (var categories, int total) = await _uow.Categories.SearchCategory(request.FullText, skip, request.PageSize); if (categories == null) { return(new ResponseList <CategoryResponse>(ResponseStatus.NotFound, null, ResponseMessagesConstans.NotFound)); } return(new ResponseList <CategoryResponse>(ResponseStatus.Ok, _mapService.MapCategories(categories), total)); }
public async Task <CategoryListViewModel> GetPagedListAsync(CategorySearchRequest request) { var result = _category .ProjectTo <CategoryDetailViewModel>(_mappingEngine); if (!string.IsNullOrWhiteSpace(request.Title)) { result = result.Where(a => a.Title.Contains(request.Title) || a.Description.Contains(request.Title)).AsQueryable(); } request.Total = result.Count(); var resultsToSkip = (request.PageIndex - 1) * request.PageSize; var query = await result .OrderByDescending(r => r.Id) .Skip(() => resultsToSkip) .Take(() => request.PageSize) .ToListAsync(); return(new CategoryListViewModel { Categories = query, SearchRequest = request }); }
public async Task <JsonResultModel <CategoryInfo> > GetPageList([FromQuery] CategorySearchRequest searchRequest) { return(await _categoryBusiness.GetPageList(searchRequest)); }
public IActionResult Get([FromBody] CategorySearchRequest request) { return(Ok(_categoryService.Get(request))); }
public async Task <IHttpActionResult> Search([FromUri] CategorySearchRequest request) { var response = await _categoryService.Search(request); return(new CreateResult(response)); }
public IList <CategoryDto> Get(CategorySearchRequest request) { var categories = _context.Categories.Where(a => a.Title.Contains(request.Title)).ToList(); return(_mapper.Map <IList <CategoryDto> >(categories)); }