Ejemplo n.º 1
0
        public async Task <ICollection <LessonType> > GetLessonTypesAsync(LessonTypeQuery query)
        {
            Expression <Func <LessonType, bool> > predicate = entity =>
                                                              (query.FilterTitleLike == null || entity.Title.Contains(query.FilterTitleLike)) &&
                                                              (query.FilterActive == null || entity.OnSale == query.FilterActive.Value);

            return(await _repository.GetSomeAsync(query.FilterIds, predicate, query.Skip, query.Take,
                                                  query.OrderBy, query.OrderMode));
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <LessonTypeModel> > GetAsync([FromQuery] string titleLike,
                                                                    [FromQuery] bool?active, int?take, int?skip, string orderBy, string orderMode)
        {
            var query = new LessonTypeQuery
            {
                Take            = take,
                Skip            = skip,
                OrderBy         = orderBy,
                OrderMode       = orderMode,
                FilterTitleLike = titleLike,
                FilterActive    = active,
            };
            var entities = await _service.GetLessonTypesAsync(query);

            return(_mapper.Map <IEnumerable <LessonTypeModel> >(entities));
        }