public async Task <IActionResult> Category(string category, [FromQuery] PagingModel paging = null)
        {
            var model = new PEngineGenericListModel <ArticleModel>(_svp, HttpContext, false);

            if (paging != null)
            {
                paging.Count = paging.Count > 0 ? paging.Count : model.Settings.PerPagePostArchived;
                if (string.IsNullOrEmpty(paging.SortField))
                {
                    paging.SortField     = "Name";
                    paging.SortAscending = false;
                }
            }
            var articles = (await _articleService.ListArticles(category, model.State.HasAdmin)).ToList();

            if (!articles.Any())
            {
                return(model.State.HasAdmin ? (IActionResult)this.Redirect(Settings.Current.BasePath) : this.NotFound());
            }
            if (articles.Count > 1 || model.State.HasAdmin)
            {
                model.ListData = PagingUtils.Paginate <ArticleModel>(ref paging, articles);
                model.Paging   = paging;
                return(View("List", model));
            }
            else
            {
                return(Redirect($"{Settings.Current.BasePath}article/view/{articles.First().UniqueName}"));
            }
        }
Exemplo n.º 2
0
        public List <StudentViewModel> GetStudentList(SearchRequestModel <StudentViewModel> input)
        {
            string query = string.Format(@"SELECT @@COLUMNNAME@@
                            FROM STUDENT s JOIN USER_MASTER u ON s.user_id=u.id
                            JOIN STUDENT_BRANCHES sb ON sb.student_id=s.id
                            JOIN CUSTOMER_BRANCHES b ON sb.branch_id=b.id
                            WHERE (0={0} OR u.customer_id={0}) 
                                AND (0={1} OR u.id={1}) 
                                AND (0={2} OR s.id={2}) 
                                AND (0={3} OR sb.branch_id={3}) 
                                ORDER BY s.id 
                             LIMIT {4},{5}", input.CustomerId,
                                         input.RequestParameter.UserId,
                                         input.RequestParameter.StudentId,
                                         input.RequestParameter.BranchId,
                                         PagingUtils.MySQLStartLimit(input.PageNumber, input.PageSize),
                                         input.PageSize);

            #region total record count
            string queryCount   = query.Replace("@@COLUMNNAME@@", " count(s.id) studentCount ");
            var    studentCount = this.RepositoryContext.ExecuteSqlQuery <Int32>(queryCount).FirstOrDefault();
            #endregion

            string studentListquery             = query.Replace("@@COLUMNNAME@@", @" s.id  StudentId,u.id  UserId,u.first_name FirstName,u.middle_name MiddleName,u.last_name LastName,
                            u.primary_contactno PrimaryContact, u.login_id LoginId, u.notification_id NotificationId, sb.branch_id BranchId,
                            b.name BranchName ");
            List <StudentViewModel> studentList = this.RepositoryContext.ExecuteSqlQuery <StudentViewModel>(studentListquery).ToList();
            //add the counter property...need to relook
            studentList.ForEach(x => x.Counter = studentCount);

            return(studentList);
        }
Exemplo n.º 3
0
        private void BindNavigationLinks()
        {
            int pageCount = PagingUtils.CalculatePageCount(this.DirectoryList.Count, m_pageSize);

            this.MainContentHtml = this.MainContentHtml.Replace("[UpStatus]", m_pageIndex > 1 ? "On" : "Off");
            this.MainContentHtml = this.MainContentHtml.Replace("[DownStatus]", m_pageIndex < pageCount ? "On" : "Off");

            string previousPageLink = String.Empty;

            if (m_pageIndex > 1)
            {
                previousPageLink = this.GetTemplate("Browse\\PreviousPageLink.htm");
                previousPageLink = previousPageLink.Replace("[PreviousPageUrl]", NavigationManager.GetBrowsePageUrl(this.BrowseUrl, m_pageIndex - 1));
            }
            this.MainContentHtml = this.MainContentHtml.Replace("<PreviousPageLink>", previousPageLink);

            string nextPageLink = String.Empty;

            if (m_pageIndex < pageCount)
            {
                nextPageLink = this.GetTemplate("Browse\\NextPageLink.htm");
                nextPageLink = nextPageLink.Replace("[NextPageUrl]", NavigationManager.GetBrowsePageUrl(this.BrowseUrl, m_pageIndex + 1));
            }
            this.MainContentHtml = this.MainContentHtml.Replace("<NextPageLink>", nextPageLink);
        }
        public async Task <IActionResult> Index([FromQuery] string query, [FromQuery] PagingModel paging = null)
        {
            var model = new PEngineGenericListModel <PEngineSearchResultModel>(HttpContext, false);

            model.State.CurrentSection = query;

            var results = new List <PEngineSearchResultModel>();

            string[] searchTerms = !string.IsNullOrWhiteSpace(query) ? query.Split(' ') : new string[] {};

            results.AddRange((await _articleService.SearchArticles(searchTerms, model.State.HasAdmin))
                             .Select(a => new PEngineSearchResultModel(a)));

            results.AddRange((await _postService.SearchPosts(searchTerms, model.State.HasAdmin))
                             .Select(p => new PEngineSearchResultModel(p)));

            if (!Settings.Current.DisableForum)
            {
                results.AddRange((await _forumService.SearchForumThreadPosts(searchTerms, model.State.HasForumAdmin))
                                 .Select(ftp => new PEngineSearchResultModel(ftp)));
            }

            if (paging != null)
            {
                paging.Count = paging.Count > 0 ? paging.Count : model.Settings.PerPageSearchResults;
                if (string.IsNullOrEmpty(paging.SortField))
                {
                    paging.SortField     = "CreatedUTC";
                    paging.SortAscending = false;
                }
            }
            model.ListData = PagingUtils.Paginate <PEngineSearchResultModel>(ref paging, results);
            model.Paging   = paging;
            return(View(model));
        }
        public async Task <IActionResult> Index([FromQuery] string query, [FromQuery] PagingModel paging = null)
        {
            var model = new PEngineGenericListModel <PEngineSearchResultModel>(_svp, HttpContext, false);

            if (!Settings.Current.DisableSearch)
            {
                model.State.CurrentSection = query;

                var      results     = new List <PEngineSearchResultModel>();
                string[] searchTerms = !string.IsNullOrWhiteSpace(query) ? query.Split(' ') : new string[] {};

                var articleResults = (await _articleService.SearchArticles(query, searchTerms, model.State.HasAdmin));
                results.AddRange(articleResults.exact.Select(a => new PEngineSearchResultModel(a, true)));
                results.AddRange(articleResults.fuzzy.Select(a => new PEngineSearchResultModel(a, false)));

                var postResults = (await _postService.SearchPosts(query, searchTerms, model.State.HasAdmin));
                results.AddRange(postResults.exact.Select(p => new PEngineSearchResultModel(p, true)));
                results.AddRange(postResults.fuzzy.Select(p => new PEngineSearchResultModel(p, false)));

                if (paging != null)
                {
                    paging.Count = paging.Count > 0 ? paging.Count : model.Settings.PerPageSearchResults;
                    if (string.IsNullOrEmpty(paging.SortField))
                    {
                        paging.SortField     = "ExactMatch DESC, CreatedUTC";
                        paging.SortAscending = false;
                    }
                }
                model.ListData = PagingUtils.Paginate <PEngineSearchResultModel>(ref paging, results);
                model.Paging   = paging;
                return(View(model));
            }
            return(model.State.HasAdmin ? (IActionResult)this.Redirect(Settings.Current.BasePath) : this.NotFound());
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Index()
        {
            var model = new PEngineGenericListModel <PostModel>(_svp, HttpContext, true);

            model.ListData        = PagingUtils.Paginate(1, model.Settings.PerPagePostFront, "CreatedUTC", false, await _postService.ListPosts(model.State.HasAdmin));
            model.State.QuoteText = (await _quoteService.GetRandom()).Data;
            return(View(model));
        }
Exemplo n.º 7
0
        public async Task <PaginatedPaymentsModel> GetPendingPaymentRequestsForCustomerAsync(string customerId, int currentPage, int pageSize)
        {
            var(skip, take) = PagingUtils.GetNextPageParameters(currentPage, pageSize);

            var(paymentRequests, totalCount) = await _paymentsRepository.GetPendingPaymentRequestsForCustomerAsync(customerId, skip, take);

            return(new PaginatedPaymentsModel
            {
                CurrentPage = currentPage,
                PageSize = pageSize,
                PaymentRequests = paymentRequests,
                TotalCount = totalCount
            });
        }
Exemplo n.º 8
0
        public async Task <TransactionReportResult> GetPaginatedAsync(
            int currentPage, int pageSize,
            DateTime from, DateTime to)
        {
            var(skip, take) = PagingUtils.GetNextPageParameters(currentPage, pageSize);

            var reports = await _transactionReportRepository.GetPaginatedAsync(skip, take, from, to);

            return(new TransactionReportResult
            {
                CurrentPage = currentPage,
                PageSize = pageSize,
                TotalCount = reports.Count,
                TransactionReports = reports
            });
        }
        public async Task <IActionResult> List([FromQuery] PagingModel paging = null)
        {
            var model = new PEngineGenericListModel <PostModel>(HttpContext, false);

            if (paging != null)
            {
                paging.Count = paging.Count > 0 ? paging.Count : model.Settings.PerPagePostArchived;
                if (string.IsNullOrEmpty(paging.SortField))
                {
                    paging.SortField     = "CreatedUTC";
                    paging.SortAscending = false;
                }
            }
            model.ListData = PagingUtils.Paginate <PostModel>(ref paging, await _postService.ListPosts(model.State.HasAdmin));
            model.Paging   = paging;
            return(View(model));
        }
Exemplo n.º 10
0
        public List <VMActivityLog> GetActivityLogs(PageModel pageModel)
        {
            var data = (from activity in _context.ActivityLogs
                        join user in _context.UserMasters on activity.ActivityBy equals user.UserId
                        join role in _context.RoleMasters on user.Role equals role.RoleId
                        //where activity.ActivityBy > 0
                        select new
            {
                ActivityOn = activity.ActivityOn,
                ActivityByName = activity.ActivityBy,
                ActivityLogId = activity.ActivityLogId,
                ActivityTime = activity.ActivityTime,
                ActivityType = activity.ActivityType,
                ActivityFor = activity.ActivityFor
            }).ToList();
            int totalRecords = data.Count;

            var data2 = (from d in data
                         select new VMActivityLog
            {
                ActivityOn = (d.ActivityFor == "Role") ? _context.RoleMasters
                             .Where(x => x.RoleId == d.ActivityOn)
                             .Select(x => x.RoleName).FirstOrDefault()
                                                                    : _context.UserMasters
                             .Where(x => x.UserId == d.ActivityOn)
                             .Select(x => x.UserName).FirstOrDefault(),
                ActivityByName = _context.UserMasters.Where(x => x.UserId == d.ActivityByName)
                                 .Select(x => x.UserName).FirstOrDefault(),
                ActivityLogId = d.ActivityLogId,
                ActivityTime = d.ActivityTime,
                ActivityType = d.ActivityType,
                ActivityFor = d.ActivityFor,
                TotalRecords = totalRecords
            }).ToList();

            if (pageModel.SortOrder == "desc")
            {
                data2 = PagingUtils.OrderDesc <VMActivityLog>(data2.AsQueryable <VMActivityLog>(), pageModel).ToList();
            }
            else
            {
                data2 = PagingUtils.OrderAsc <VMActivityLog>(data2.AsQueryable <VMActivityLog>(), pageModel).ToList();
            }
            return(data2);
        }
Exemplo n.º 11
0
        public async Task <TransactionsResult> GetFilteredAsync(TransactionsFilter filter, int currentPage, int pageSize)
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            var(skip, take) = PagingUtils.GetNextPageParameters(currentPage, pageSize);

            var items = await _transactionRepository.GetFilteredAsync(filter, skip, take);

            return(new TransactionsResult
            {
                CurrentPage = currentPage,
                PageSize = pageSize,
                Transactions = items
            });
        }
Exemplo n.º 12
0
        public async Task <TransactionReportResult> GetPaginatedAsync(
            int currentPage, int pageSize,
            DateTime from, DateTime to, string[] partnerIds, Guid?campaignId,
            string transactionType = null, string status = null)
        {
            var(skip, take) = PagingUtils.GetNextPageParameters(currentPage, pageSize);

            var reports = await _transactionReportRepository.GetPaginatedAsync(skip, take, from, to, partnerIds,
                                                                               transactionType, status, campaignId);

            return(new TransactionReportResult
            {
                CurrentPage = currentPage,
                PageSize = pageSize,
                TotalCount = reports.Count,
                TransactionReports = reports
            });
        }
Exemplo n.º 13
0
        public async Task <EventsResult> GetByTransactionAsync(string txHash, int currentPage, int pageSize)
        {
            if (string.IsNullOrEmpty(txHash))
            {
                throw new ArgumentException("Transaction hash can't be empty", nameof(txHash));
            }

            var(skip, take) = PagingUtils.GetNextPageParameters(currentPage, pageSize);

            var queryResult = await _eventRepository.GetByTransactionAsync(txHash, skip, take);

            return(new EventsResult
            {
                CurrentPage = currentPage,
                PageSize = pageSize,
                Events = queryResult.Item2,
                TotalCount = queryResult.total
            });
        }
Exemplo n.º 14
0
        /*
         * public static DirectoryListEntryCollection GetFiltered(DirectoryListEntryCollection collection, DirectoryListEntryColumnName columnName, object value)
         * {
         *      return GetFiltered(collection, columnName.ToString(), value);
         * }
         *
         * public static DirectoryListEntryCollection GetFiltered(DirectoryListEntryCollection collection, string columnName, object value)
         * {
         *      DirectoryListEntryCollection result = new DirectoryListEntryCollection();
         *
         *      if (value is bool)
         *      {
         * value = Convert.ToByte(value);
         *      }
         *
         *      foreach (DirectoryListEntry entity in collection)
         *      {
         *              if (entity[columnName].Equals(value))
         *              {
         *                      result.Add(entity);
         *              }
         *      }
         *      return result;
         * }
         *
         * public static DirectoryListEntryCollection GetFiltered(DirectoryListEntryCollection collection, DirectoryListEntryColumnName columnName, object value, ComparisonOperator comparisonOperator)
         * {
         *      return GetFiltered(collection, columnName.ToString(), value, comparisonOperator);
         * }
         *
         * //Approximately 2.5 Times Slower Than Direct Approach (e.g. value >= entity.DisplayOrder), but still very fast and useful.
         * public static DirectoryListEntryCollection GetFiltered(DirectoryListEntryCollection collection, string columnName, object value, ComparisonOperator comparisonOperator)
         * {
         * DirectoryListEntryCollection result = new DirectoryListEntryCollection();
         *
         * if (value is bool)
         * {
         * value = Convert.ToByte(value);
         * }
         *
         * foreach (DirectoryListEntry entity in collection)
         * {
         *              int comparisonResult = entity.CompareField(columnName, value);
         *              if (ComparisonUtils.DoesComparisonMatch(comparisonOperator, comparisonResult))
         * {
         *  result.Add(entity);
         * }
         * }
         * return result;
         * }
         *
         * public static DirectoryListEntryCollection GetBlocked(DirectoryListEntryCollection collection, DirectoryListEntryColumnName columnName, object value)
         * {
         *      return GetBlocked(collection, columnName.ToString(), value);
         * }
         *
         * public static DirectoryListEntryCollection GetBlocked(DirectoryListEntryCollection collection, string columnName, object value)
         * {
         *      DirectoryListEntryCollection result = new DirectoryListEntryCollection();
         *
         *      if (value is bool)
         *      {
         * value = Convert.ToByte(value);
         *      }
         *
         *      foreach (DirectoryListEntry entity in collection)
         *      {
         *              if (!entity[columnName].Equals(value))
         *              {
         *                      result.Add(entity);
         *              }
         *      }
         *      return result;
         * }
         *
         * public static int GetCount(DirectoryListEntryCollection collection, DirectoryListEntryColumnName columnName, object value)
         * {
         *      int result = 0;
         *
         *      if (value is bool)
         *      {
         * value = Convert.ToByte(value);
         *      }
         *
         *      foreach (DirectoryListEntry entity in collection)
         *      {
         *              if (entity[columnName.ToString()].Equals(value))
         *              {
         *                      result++;
         *              }
         *      }
         *      return result;
         * }
         */
        public static DirectoryListEntryCollection GetPage(DirectoryListEntryCollection collection, int pageIndex, int pageSize)
        {
            DirectoryListEntryCollection page = new DirectoryListEntryCollection();

            int firstItemIndex = PagingUtils.GetFirstItemIndex(pageIndex, pageSize);
            int lastItemIndex  = PagingUtils.GetLastItemIndex(pageIndex, pageSize);

            if (lastItemIndex >= collection.Count)
            {
                lastItemIndex = collection.Count - 1;
            }

            for (int index = firstItemIndex; index < lastItemIndex + 1; index++)
            {
                page.Add((DirectoryListEntry)collection[index]);
            }

            return(page);
        }
Exemplo n.º 15
0
        public async Task <TransactionsResult> GetByBlockAsync(string blockHash, int currentPage, int pageSize)
        {
            if (string.IsNullOrEmpty(blockHash))
            {
                throw new ArgumentException("Block hash can't be empty", nameof(blockHash));
            }

            var(skip, take) = PagingUtils.GetNextPageParameters(currentPage, pageSize);

            var queryResult = await _transactionRepository.GetByBlockHashAsync(blockHash, skip, take);

            return(new TransactionsResult
            {
                CurrentPage = currentPage,
                PageSize = pageSize,
                Transactions = queryResult.Item2,
                TotalCount = queryResult.total
            });
        }
Exemplo n.º 16
0
        public async Task <TransactionsResult> GetByBlockAsync(long blockNumber, int currentPage, int pageSize)
        {
            if (blockNumber < 0)
            {
                throw new ArgumentException("Block number can't be negative", nameof(blockNumber));
            }

            var(skip, take) = PagingUtils.GetNextPageParameters(currentPage, pageSize);

            var queryResult = await _transactionRepository.GetByBlockNumberAsync(blockNumber, skip, take);

            return(new TransactionsResult
            {
                CurrentPage = currentPage,
                PageSize = pageSize,
                Transactions = queryResult.Item2,
                TotalCount = queryResult.total
            });
        }
Exemplo n.º 17
0
        private void BindList()
        {
            string        listEntryHtml = GetTemplate("Browse\\DirectoryListEntry.htm");
            StringBuilder builder       = new StringBuilder();

            DirectoryListEntryCollection collection = this.DirectoryList;
            DirectoryListEntryCollection page       = this.DirectoryListPage;

            int pageCount = PagingUtils.CalculatePageCount(this.DirectoryList.Count, m_pageSize);

            int index = 1;

            foreach (DirectoryListEntry entry in page)
            {
                string entryHtml = listEntryHtml;
                entryHtml = entryHtml.Replace("[Name]", entry.Name);
                entryHtml = entryHtml.Replace("[NavigateUrl]", entry.NavigateUrl);
                int displayOrder = (this.PageIndex - 1) * 10 + index;
                entryHtml = entryHtml.Replace("[DisplayOrder]", displayOrder.ToString());
                entryHtml = entryHtml.Replace("[NextDisplayOrder]", (displayOrder + 1).ToString());
                entryHtml = entryHtml.Replace("[IconName]", entry.IconName);
                if (m_pageIndex > 1 && index == 1)
                {
                    entry.BrowserTags = entry.BrowserTags + " onkeyupset=\"prev\"";
                }
                if (m_pageIndex < pageCount && index == m_pageSize)
                {
                    entry.BrowserTags = entry.BrowserTags + " onkeydownset=\"next\"";
                }
                entryHtml = entryHtml.Replace("[BrowserTags]", entry.BrowserTags);

                builder.Append(entryHtml);
                index++;
            }

            this.MainContentHtml = this.MainContentHtml.Replace("<List>", builder.ToString());
        }
        public List <VMRoleMaster> GetRoles(PageModel pageModel)
        {
            List <VMRoleMaster> data = new List <VMRoleMaster>();

            var data2        = _context.RoleMasters.ToList();
            int totalRecords = data.Count;

            data = (from d in data2
                    select new VMRoleMaster
            {
                RoleId = d.RoleId,
                RoleName = d.RoleName,
                TotalRecords = totalRecords
            }).ToList();
            if (pageModel.SortOrder == "desc")
            {
                data = PagingUtils.OrderDesc <VMRoleMaster>(data.AsQueryable <VMRoleMaster>(), pageModel).ToList();
            }
            else
            {
                data = PagingUtils.OrderAsc <VMRoleMaster>(data.AsQueryable <VMRoleMaster>(), pageModel).ToList();
            }
            return(data);
        }
Exemplo n.º 19
0
        public async Task <IEnumerable <PostModel> > Get([FromQuery] PagingModel paging = null)
        {
            var posts = await _postDal.ListPosts();

            return(PagingUtils.Paginate(ref paging, posts));
        }
Exemplo n.º 20
0
        public async Task <IEnumerable <QuoteModel> > Get([FromQuery] PagingModel paging = null)
        {
            var quotes = await _quoteService.Get();

            return(PagingUtils.Paginate(ref paging, quotes));
        }
        public async Task <IEnumerable <ArticleModel> > Get(string category, [FromQuery] PagingModel paging = null)
        {
            var articles = await _articleDal.ListArticles(category);

            return(PagingUtils.Paginate(ref paging, articles));
        }
        public async Task <IEnumerable <ForumUserModel> > GetForumUsers([FromQuery] PagingModel paging = null)
        {
            var forumUsers = await _forumDal.ListForumUsers();

            return(PagingUtils.Paginate(ref paging, forumUsers));
        }
        public async Task <IEnumerable <ForumThreadModel> > GetForumThreads(Guid forumGuid, [FromQuery] PagingModel paging = null)
        {
            var forumThreads = await _forumService.ListForumThreads(forumGuid, null, HttpContext.User.IsInRole("ForumAdmin"));

            return(PagingUtils.Paginate(ref paging, forumThreads));
        }