Exemplo n.º 1
0
        public async System.Threading.Tasks.Task <ActionResult> ListAsync(long?id, int?pageIndex, int?pageSize)
        {
            var result = new ResultModel();

            if (id == null || id < 0)
            {
                result.Code    = 1002;
                result.Message = " id ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            if (pageIndex == null || pageIndex < 0)
            {
                result.Code    = 1002;
                result.Message = " pageIndex ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            if (pageSize == null || pageSize < 0)
            {
                result.Code    = 1002;
                result.Message = " pageSize ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            try
            {
                var list = (await repository.GetAllListAsync((int)pageIndex, (int)pageSize, m => m.articleId == id && m.status == 0)).ToList();
                if (list != null && list.Count > 0)
                {
                    var data = Mapper.Map <IList <ArticleComment>, IList <CommentListModel> >(list);
                    result.Code       = 0;
                    result.Message    = string.Empty;
                    result.Data       = data;
                    result.allpageNum = await repository.CountAsync(m => m.articleId == id && m.status == 0);

                    return(Jsonp(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    result.Code    = 1003;
                    result.Message = "not found";
                    return(Jsonp(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1001;
                result.Message = ex.Message;
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 2
0
        public async Task <int> remain()
        {
            var res    = new EasonRepository <ShortMessage, long>();
            int result = 0;
            int cost   = await res.CountAsync();

            var list = await repository.GetAllListAsync();

            foreach (var item in list)
            {
                result += item.count;
            }
            result = result - cost;
            return(result);
        }
Exemplo n.º 3
0
        public async System.Threading.Tasks.Task <ActionResult> Index(int?pageIndex, int?pageSize)
        {
            EasonRepository <IndexBanner, long> idx = new EasonRepository <IndexBanner, long>();;
            var result = new ResultModel();


            if (pageIndex == null || pageIndex < 0)
            {
                result.Code    = 1002;
                result.Message = " pageIndex ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            if (pageSize == null || pageSize < 0)
            {
                result.Code    = 1002;
                result.Message = " pageSize ";
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
            try
            {
                var list = (await idx.GetAllListAsync((int)pageIndex, (int)pageSize, m => m.status == 0)).ToList();
                if (list != null && list.Count() > 0)
                {
                    ;
                    result.Code       = 0;
                    result.Message    = string.Empty;
                    result.Data       = list;
                    result.allpageNum = await idx.CountAsync(m => m.status == 0);

                    return(Jsonp(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    result.Code    = 0;
                    result.Message = "not found";
                    return(Jsonp(result, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1001;
                result.Message = ex.Message;
                return(Jsonp(result, JsonRequestBehavior.AllowGet));
            }
        }