예제 #1
0
        /// <summary>
        /// Get all coincidences that found in the database records
        /// </summary>
        /// <param name="searchString"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public async Task <ActionResult> SearchedItems(string searchString, int page = 1)
        {
            List <DayBookModel>        Mathes = new List <DayBookModel>();
            IEnumerable <DayBookModel> matchedRecords;
            string currentUserId = User.Identity.GetUserId();
            var    daybooks      = await db.DayBooks.Where(p => p.ApplicationUserId.Equals(currentUserId)).ToListAsync();

            if (daybooks != null)
            {
                if (daybooks.Count > 0)
                {
                    daybooks = DectyptRecords(daybooks);
                }
            }

            if (!String.IsNullOrEmpty(searchString))
            {
                matchedRecords = daybooks.Where(p => p.DayRecord.Contains(searchString));
                Mathes         = matchedRecords.ToList();
            }

            int pageSize = 3;
            IEnumerable <DayBookModel> recordsPerPage = Mathes.Skip((page - 1) * pageSize).Take(pageSize);
            PageInfo pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = Mathes.Count
            };

            Models.Pagination.IndexViewModel ivm = new Models.Pagination.IndexViewModel {
                PageInfo = pageInfo, Records = recordsPerPage
            };
            return(View(ivm));
        }
예제 #2
0
        public async Task <ActionResult> Index(int page = 1)
        {
            string currentUserId = User.Identity.GetUserId();
            var    daybooks      = await db.DayBooks.Where(p => p.ApplicationUserId.Equals(currentUserId)).ToListAsync();

            if (daybooks != null)
            {
                if (daybooks.Count > 0)
                {
                    daybooks = DectyptRecords(daybooks);
                }
            }
            int pageSize = 3;
            IEnumerable <DayBookModel> recordsPerPage = daybooks.Skip((page - 1) * pageSize).Take(pageSize);
            PageInfo pageInfo = new PageInfo {
                PageNumber = page, PageSize = pageSize, TotalItems = daybooks.Count
            };

            Models.Pagination.IndexViewModel ivm = new Models.Pagination.IndexViewModel {
                PageInfo = pageInfo, Records = recordsPerPage
            };
            return(View(ivm));
        }