Exemplo n.º 1
0
        public JsonResult Gets(string key = "", int page = 1, int pageSize = 5)
        {
            try
            {
                List <Author> 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));
            }
        }
Exemplo n.º 2
0
        //[HttpPost]
        //public JsonResult LoadData()
        //{
        //    IEnumerable<AuthorViewModel> model =
        //}
        //public JsonResult LoadData()
        //{
        //    setViewbagforAuthor();
        //    List<Author> model = new AuthorDAO().getListAuthor();
        //    model = model.OrderBy(x => x.Name).ToList();
        //    var TotalRow = model.Count();
        //    return Json(new
        //    {
        //        data = model,
        //        totalRow = TotalRow,
        //        status = true
        //    }, JsonRequestBehavior.AllowGet);
        //}

        public JsonResult LoadData()
        {
            setViewbagforAuthor();
            List <Author> model = new AuthorDAO().getListAuthor();

            model = model.OrderBy(x => x.Name).ToList();
            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);
        }