コード例 #1
0
        public JsonResult GetLocales(int page = 1, int limit = 10)
        {
            var locales = _localService.GetPagedList(page > 0 ? page - 1 : page, limit);
            var records = locales.Items;
            var total   = locales.TotalCount;

            return(Json(
                       new { records, total }
                       , JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public async Task <IHttpActionResult> Get(Guid cadenaId, int?page = 1, int?pageSize = 10)
        {
            var pagedSet = new PaginationSet <LocalDto>();

            try
            {
                if (await _authorizationService.AuthorizeAsync(User))
                {
                    var currentPage     = page.Value;
                    var currentPageSize = pageSize.Value;

                    var locales    = _localService.GetPagedList(cadenaId, currentPage > 0 ? currentPage - 1 : currentPage, currentPageSize);
                    var localesDto = Mapper.Map <IEnumerable <Local>, IEnumerable <LocalDto> >(locales.Items);

                    pagedSet = new PaginationSet <LocalDto>
                    {
                        Page       = currentPage,
                        TotalCount = (int)locales.TotalCount,
                        TotalPages = locales.TotalPages,
                        Items      = localesDto
                    };
                }
                else
                {
                    var codeResult = new CodeResultStatus(401);
                    return(Ok(codeResult));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(Ok(pagedSet));
        }