Example #1
0
        public IActionResult Search(
            [FromQuery] SearchParams searchParams,
            [FromQuery] PagerParams pagerParams,
            [FromQuery] SortParams sortParams
            )
        {
            var userId = _user.GetCurrentUserId();

            var result = _noteService.Search(searchParams, sortParams);
            var count  = result.Count();
            var notes  = result.Select(x => new
            {
                x.Id,
                x.Name,
                x.Description,
                x.Price,
                x.Semester,
                x.PageCount,
                x.PreviewUrl,
                owned = x.AuthorId == userId || x.Buyers.Any(xd => xd.UserId == userId),

                Author = new
                {
                    Id   = x.AuthorId,
                    Name = x.Author.UserName
                },
                Course = new
                {
                    Id = x.CourseId, x.Course.Name
                },
                University = new
                {
                    Id = x.Course.UniversityId, x.Course.University.Name
                },
                Voivodeship = new
                {
                    Id = x.Course.University.VoivodeshipId, x.Course.University.Voivodeship.Name
                }
            });

            return(Ok(new
            {
                Pager = new PagerResult
                {
                    Size = pagerParams.Size,
                    Page = pagerParams.Page,
                    Count = count,
                    Pages = (int)Math.Ceiling(count / (float)pagerParams.Size)
                },
                Notes = notes
                        .Skip((pagerParams.Page - 1) * pagerParams.Size)
                        .Take(pagerParams.Size)
            }));
        }
        public ActionResult EmployeeAttendanceList(int?page)
        {
            if (!_permissionService.Authorize("ManageEmployeeAttendance"))
            {
                return(AccessDeniedView());
            }

            int         currentPageIndex   = page.HasValue ? page.Value - 1 : 0;
            PagerParams param              = new PagerParams(10, currentPageIndex, -1);
            var         employeeAttendance = _smsService.GetEmployeeAttendanceByDateAndEmployee(param, null, 0);
            var         model              = new EmployeeAttendanceOverviewModel();

            if (employeeAttendance.TotalCount > 0)
            {
                model.LoadPagedList(employeeAttendance);
            }

            return(View(model));
        }