Exemplo n.º 1
0
        public JsonResult LoadData()
        {
            setViewbagforPub();
            IEnumerable <Publisher> model = new PublisherDAO().getListPublisher();

            model = model.OrderBy(x => x.Name);
            var TotalRow = model.Count();
            var output   = JsonConvert.SerializeObject(model, new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });
            var jsonresult = Json(new
            {
                data     = output,
                totalRow = TotalRow,
                status   = true
            }, JsonRequestBehavior.AllowGet);

            jsonresult.MaxJsonLength = int.MaxValue;
            return(jsonresult);
        }
        public JsonResult Gets(string key = "", int page = 1, int pageSize = 5)
        {
            try
            {
                List <Publisher> data = dao.Gets(key, page, pageSize);
                int totalRow          = dao.Count(key);

                return(Json(new
                {
                    data = data,
                    totalRow = totalRow
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new
                {
                    data = DBNull.Value.ToString()
                }, JsonRequestBehavior.AllowGet));
            }
        }