Example #1
0
        public async Task <PaginationResultModel> GetByFilter(PaginationParamsModel paginationParams)
        {
            PaginationResultModel response = new PaginationResultModel();

            string searchString = paginationParams.SearchString;

            IQueryable <SucceededOperation> operations = _userDbContext.SucceededOperations.Where(operation => operation.AccountId == paginationParams.AccountId);

            if (!string.IsNullOrEmpty(searchString))
            {
                operations = operations.Where(operation => operation.AccountId.ToString().Contains(searchString) ||
                                              operation.Id.ToString().Contains(searchString) ||
                                              operation.Balance.ToString().Contains(searchString) ||
                                              operation.OperationTime.ToString().Contains(searchString) ||
                                              operation.TransactionAmount.ToString().Contains(searchString)
                                              );
            }

            response.OperationsTotal = await operations.CountAsync();

            SortField sortField = paginationParams.SortField;

            List <SucceededOperation> operationList = await operations
                                                      .OrderBy(sortField.ToString(), paginationParams.SortDirection
                                                               .ToString() == "Asc"?false : true)
                                                      .Skip((paginationParams.PageIndex) * paginationParams.PageSize).Take(paginationParams.PageSize)
                                                      .ToListAsync();

            response.OperationsList = _mapper.Map <List <SucceededOperationModel> >(operationList);
            return(response);
        }
Example #2
0
 public object ToValues(int?page) => new
 {
     page           = page ?? Page,
     sort_field     = SortField.ToString().ToLowerInvariant(),
     sort_direction = SortDirection.ToString().ToLowerInvariant(),
     q       = Search,
     tags    = Tags,
     version = Version,
 };
Example #3
0
        public virtual void TestToString()
        {
            Expression     expr     = JavascriptCompiler.Compile("sqrt(_score) + ln(popularity)");
            SimpleBindings bindings = new SimpleBindings();

            bindings.Add(new SortField("_score", SortFieldType.SCORE));
            bindings.Add(new SortField("popularity", SortFieldType.INT32));
            SortField sf = expr.GetSortField(bindings, true);

            Assert.AreEqual("<expr \"sqrt(_score) + ln(popularity)\">!", sf.ToString());
        }
 public override NameValueCollection ToNameValueCollection()
 {
     base.ToNameValueCollection();
     if (Page.HasValue)
     {
         Nv.Add("page", Page.ToString());
     }
     if (Rating.HasValue)
     {
         Nv.Add("rating", Rating.ToString());
     }
     if (!string.IsNullOrEmpty(SortField))
     {
         Nv.Add("sortfield", SortField.ToString());
     }
     if (!string.IsNullOrEmpty(SortOrder))
     {
         Nv.Add("sortorder", SortOrder.ToString());
     }
     return(Nv);
 }
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"SortField = {(SortField == null ? "null" : SortField.ToString())}");
     toStringOutput.Add($"SortOrder = {(SortOrder == null ? "null" : SortOrder.ToString())}");
 }
Example #6
0
 protected bool IsSortByPoint(UserPointType type)
 {
     return(SortField.ToString() == type.ToString());
 }
Example #7
0
        private string GetSortField(SortField sortField)
        {
            string val = string.Empty;

            switch (sortField)
            {
                case SortField.StartTime:
                    val = "start_time";
                    break;

                case SortField.Type:
                    val = "type";
                    break;

                case SortField.QueueAccountId:
                    val = "queue_account_id";
                    break;

                case SortField.CallerIdNumber:
                    val = "caller_id_number";
                    break;

                case SortField.WaitTime:
                    val = "wait_time";
                    break;

                case SortField.TalkTime:
                    val = "talk_time";
                    break;

                case SortField.MemberAccountId:
                    val = "member_account_id";
                    break;

                case SortField.EnterPosition:
                    val = "enter_position";
                    break;

                case SortField.ExitPosition:
                    val = "exit_position";
                    break;

                case SortField.AbandonPosition:
                    val = "abandon_position";
                    break;

                default:
                    throw new NotImplementedException("No handler for the value " + sortField.ToString() + " has been implemented.");
            }

            return val;
        }
Example #8
0
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"Cursor = {(Cursor == null ? "null" : Cursor == string.Empty ? "" : Cursor)}");
     toStringOutput.Add($"SortField = {(SortField == null ? "null" : SortField.ToString())}");
     toStringOutput.Add($"SortOrder = {(SortOrder == null ? "null" : SortOrder.ToString())}");
 }