Ejemplo n.º 1
0
        public HttpResponseMessage GetAllaApproval(HttpRequestMessage request, string keyword, int page, int pageSize = 20)
        {
            int totalRow = 0;

            var model = _newService.GetAllNewsApproval(keyword);

            totalRow = model.Count();

            var query = model.OrderByDescending(n => n.CreatedDate).Skip(page * pageSize).Take(pageSize);

            var reponseData = Mapper.Map <IEnumerable <New>, IEnumerable <NewViewModel> >(query);

            var paginationSet = new PaginationSet <NewViewModel>()
            {
                Items      = reponseData,
                Page       = page,
                TotalCount = totalRow,
                TotalPages = (int)Math.Ceiling((decimal)totalRow / pageSize)
            };
            HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK, paginationSet);

            return(response);
        }