Ejemplo n.º 1
0
        public ResponseInfoModel List([FromUri] GetViewSpotListInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                CheckModelState();
                int pageSize = _systemConfigurationService.GetPageSize();
                int limit    = pageSize;
                int offset   = pageSize * (input.PageIndex - 1);
                int total;
                var outputList = _viewSpotService.GetList(limit, offset, out total, input);
                json.Result = new PagingInfo()
                {
                    totalCount = total, pageCount = (int)Math.Ceiling((decimal)total / pageSize), pageSize = pageSize, list = outputList
                };
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/viewspot/list", LocalizationConst.QueryFail);
            }
            return(json);
        }
Ejemplo n.º 2
0
        public List <GetViewSpotListOutput> GetList(int limit, int offset, out int total, GetViewSpotListInput input)
        {
            string keywords = (input.Keywords ?? "").Trim();
            var    temp     = db.ViewSpots.Where(a => string.IsNullOrEmpty(keywords) || a.Name.Contains(keywords));

            total = temp.Count();

            var list = temp.OrderBy(a => a.OrderID).ThenByDescending(a => a.CreatTime).Skip(offset).Take(limit).Select(s => new GetViewSpotListOutput()
            {
                ID      = s.ID,
                Name    = s.Name ?? "",
                OrderID = s.OrderID
            }).AsNoTracking().ToList();

            return(list);
        }