Exemplo n.º 1
0
        public async Task <ApiResult> Get(RecordSearchModel searchViewModel)
        {
            try
            {
                var list = await _recordService.FindAsync(searchViewModel);

                return(new ApiResult <PagesModel <RecordViewModel> >(new Model.PagesModel <RecordViewModel> (list, searchViewModel)));
            }
            catch (Exception)
            {
                return(new ApiResult(ReturnCode.GeneralError));
            }
        }
Exemplo n.º 2
0
        public async Task <List <Record> > FindAllAsync(RecordSearchModel searchModel)
        {
            var builder = Builders <Record> .Filter;
            var filter  = builder.Eq(m => m.State, searchModel.State);
            var list    = await _mongoHelper.FindListAsync <Record>(filter);

            searchModel.RecordCount = list.Count;
            if (searchModel.IsPagination)
            {
                return(list.OrderByDescending(m => m.CreateTime).Skip((searchModel.PageIndex - 1) * searchModel.PageSize).Take(searchModel.PageSize).ToList());
            }
            return(list.OrderByDescending(m => m.CreateTime).ToList());
        }
Exemplo n.º 3
0
        public IEnumerable <Record> Search(RecordSearchModel searchModel)
        {
            if (searchModel == null)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            IQueryable <DAL.Record> query = this.All();

            if (searchModel.Id.HasValue)
            {
                query = query.Where(r => r.RecordId == searchModel.Id.Value);
            }

            if (searchModel.CourseId.HasValue)
            {
                query = query.Where(r => r.CourseId == searchModel.CourseId.Value);
            }

            if (searchModel.ModuleNumber.HasValue)
            {
                query = query.Where(r => r.ModuleNumber.HasValue)
                        .Where(r => r.ModuleNumber.Value == searchModel.ModuleNumber.Value);
            }

            if (searchModel.RecordTypes != null && searchModel.RecordTypes.Any())
            {
                var recordTypes = searchModel.RecordTypes.ToList();
                // query = query.Where(r => recordTypes.Intersect(r.RecordTypes.AsQueryable()));
            }

            IEnumerable <Record> record = query.To <Record>()
                                          .AsQueryable();

            return(record);
        }
Exemplo n.º 4
0
        public IEnumerable <Record> GetRecords(RecordSearchModel searchModel)
        {
            IEnumerable <Record> records = this.recordsData.Records.Search(searchModel).ToList();

            return(records);
        }
Exemplo n.º 5
0
        public IEnumerable <Record> GetRecords(RecordSearchModel searchModel)
        {
            IEnumerable <Record> records = this.recordsProvider.GetRecords(searchModel);

            return(records);
        }
Exemplo n.º 6
0
        public async Task <List <RecordViewModel> > FindAsync(RecordSearchModel searchModel)
        {
            var list = await _recordRepository.FindAllAsync(searchModel);

            return(_mapper.Map <List <Record>, List <RecordViewModel> >(list));
        }