Example #1
0
        public IHttpActionResult Get(string filterText, string sortBy, SortOrder sortOrder, int pageNo, int pageSize)
        {
            try
            {
                var filteredInstruments = _instrumentsService.GetAllInstruments()
                                          .Filter(filterText);

                var instruments = filteredInstruments
                                  .SortBy(sortBy, sortOrder, x => x.Id)
                                  .Skip((pageNo - 1) * pageSize)
                                  .Take(pageSize)
                                  .ToList();

                var totalItems = filteredInstruments.Count();
                var items      = new List <InstrumentViewModel>();
                Mapper.Map(instruments, items);
                var result = new SearchResult <InstrumentViewModel>
                {
                    TotalItems = totalItems,
                    ItemList   = items
                };
                return(Ok(result));
            }
            catch
            {
                return(InternalServerError());
            }
        }
        public async Task <IActionResult> Get()
        {
            ICollection <Instrument> instruments = await _instrumentsService.GetAllInstruments();

            return(Ok(instruments));
        }