Ejemplo n.º 1
0
        public async Task <IActionResult> GetTransactions([FromQuery] DateRangeSieveModel model)
        {
            bool search = !string.IsNullOrWhiteSpace(model.SearchQuery);

            DateRange range  = new DateRange(model.Start, model.End);
            var       filter = range.Includes <Transaction>();

            if (search)
            {
                string json = await System.IO.File.ReadAllTextAsync(Path.Combine(Core.DATA_DIR, "paymentChannels.json"));

                var channels = JsonConvert.DeserializeObject <List <PaymentChannel> >(json);

                foreach (var channel in channels)
                {
                    filter = filter.Or(t => t.PaymentChannelId == channel.Id);
                }
            }


            var transactions = await DataContext.Store.GetAllAsync(filter);//await (await DataContext.Store.GetOneAsync<User>(u => u.IsPlatform)).Wallet.GetTransactions(filter);

            var data = Sieve.Apply(model, Mapper.Map <IEnumerable <BackOfficeTransactionViewModel> >(transactions).AsQueryable());

            return(Ok(data));
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> Get([FromQuery] SearchableSieveModel model)
        {
            /*
             * string role = UserRole.RegularUser.ToString();
             * string roleFilter = $"role=={role}";
             *
             * if (!model.Filters.Contains(roleFilter, StringComparison.OrdinalIgnoreCase))
             *  model.Filters += "," + roleFilter;
             */


            Core.Log.Debug("Sieve Request Recieved!");
            Core.Log.Debug($"Page: {model.Page}\nPage Size: {model.PageSize}" +
                           $"\nSorts: {model.Sorts}\nFilters: {model.Filters}\nSearch Query: {model.SearchQuery}");


            var data = UserDataContext.Users.AsNoTracking()
                       .ProjectTo <UserProfileViewModel>(Mapper.ConfigurationProvider);

            if (!string.IsNullOrWhiteSpace(model.SearchQuery))
            {
                var results = SearchEngine.Find(model.SearchQuery).ToList();
                data = data.Where(u => results.Any(r => r == u.Id));
            }

            var processedData = Sieve.Apply(model, data, applyPagination: false);
            int totalCount    = await processedData.CountAsync();


            Core.Log.Debug($"TotalCount: {totalCount}");

            processedData = Sieve.Apply(model, processedData, applySorting: false, applyFiltering: false);

            Request.HttpContext.Response.Headers.Add("X-Total-Count", totalCount.ToString());

            return(new JsonResult(await processedData.ToListAsync()));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetRequests([FromQuery] DateRangeSieveModel model)
        {
            bool      search = !string.IsNullOrWhiteSpace(model.SearchQuery);
            DateRange range  = new DateRange(model.Start, model.End);
            var       filter = range.IncludesRequest();

            var request = await DataContext.Store.GetAllAsync(filter);

            var data = Sieve.Apply(model, Mapper.Map <IEnumerable <UserDepositPaymentRequestViewModel> >(request).AsQueryable());

            if (search)
            {
                string query = model.SearchQuery.ToLower();

                data.Where(d =>
                           d.PlatformBankAccount.AccountName.ToLower().Contains(query) ||
                           d.PlatformBankAccount.AccountNumber.Contains(query) ||
                           d.Description.Contains(query));

                // TODO: Improve search.
            }

            return(Ok(data));
        }