public async Task <ActionResult <IPagedResult <Questions> > > GetPagedAsync([FromBody] QuestionRequest questionRequest) { try { var requestPaged = new PagedRequestDTO(questionRequest.PageIndex, questionRequest.PageSize); var fieldsValues = new Dictionary <string, string>(); if (questionRequest.Filters.Any()) { foreach (var filter in questionRequest.Filters) { fieldsValues.Add(filter.PropertyName, filter.PropertyValue); } } var sortData = new SortDTO(); if (questionRequest?.SortData != null) { sortData.SortDirection = questionRequest.SortData.SortDirection; sortData.SortField = questionRequest.SortData.SortField; } var result = await _questionsService.GetPagedAsync(requestPaged, fieldsValues, sortData); return(Ok(result)); } catch (Exception ex) { throw ex; } }
public IEnumerable <int> Sort(SortDTO dto) { StorageDTO data = db.GetData(); if (data != null && data.Values != null && data.Values.Count > 0) { this.IsAscending = dto.IsAscending; var sortedData = StupidSort(data.Values); return(sortedData.Take(dto.Length)); } else { throw new ValidationException("no data to sort", ""); } }
public IEnumerable <int> Sort(SortDTO dto) { StorageDTO data = db.GetData(); if (data != null && data.Values != null && data.Values.Count > 0) { this.isAscending = dto.IsAscending; List <int> arr = data.Values; int count = arr.Count; Quick_Sort(ref arr, 0, arr.Count - 1, ref count); return(arr.Take(dto.Length)); } else { throw new ValidationException("no data to sort", ""); } }
public IEnumerable <int> Sort(SortDTO dto) { StorageDTO data = db.GetData(); if (data != null && data.Values != null && data.Values.Count > 0) { List <int> sortedData; if (dto.IsAscending) { sortedData = SelectionASC(data.Values); } else { sortedData = SelectionDSC(data.Values); } return(sortedData.Take(dto.Length)); } else { throw new ValidationException("no data to sort", ""); } }