Ejemplo n.º 1
0
        public IActionResult Get()
        {
            var entities = _activityLogService.GetAll().ToList();

            //var model = entities.ToModels();
            return(Ok(entities));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetAllPaging(HttpRequestMessage request, string keyword, int page, int pageSize = 10)
        {
            return(CreateHttpResponse(request, () =>
            {
                int totalRow = 0;

                var model = _activityLogService.GetAll(keyword);
                totalRow = model.Count();
                var query = model.OrderByDescending(x => x.CreatedDate).Skip(page * pageSize).Take(pageSize);
                var responseData = Mapper.Map <IEnumerable <ActivityLog>, IEnumerable <ActivityLogViewModel> >(query);
                var paginationSet = new PaginationSet <ActivityLogViewModel>() // vif hàm không thể trả về nhièu biến nên phải gom vào pagination để trả về
                {
                    Items = responseData,

                    Page = page,
                    TotalCount = totalRow,
                    TotalPages = (int)Math.Ceiling((decimal)totalRow / pageSize)
                };
                var response = request.CreateResponse(HttpStatusCode.OK, paginationSet);
                return response;
            }));
        }