Exemple #1
0
        public JsonResult LoadData()
        {
            int draw, start, length;
            int pageIndex = 0;

            if (null != Request.Form.GetValues("draw"))
            {
                draw   = int.Parse(Request.Form.GetValues("draw").FirstOrDefault().ToString());
                start  = int.Parse(Request.Form.GetValues("start").FirstOrDefault().ToString());
                length = int.Parse(Request.Form.GetValues("length").FirstOrDefault().ToString());
            }
            else
            {
                draw   = 1;
                start  = 0;
                length = 500;
            }

            if (start == 0)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = (start / length) + 1;
            }

            RoleMasterBL bL           = new RoleMasterBL();
            int          totalrecords = 0;

            List <RoleMasterPOCO> pocoList = new List <RoleMasterPOCO>();

            pocoList = bL.GetAllRoleMasterPageWise(pageIndex, ref totalrecords, length /*, int.Parse(Session["VesselID"].ToString())*/);
            List <RoleMasterPOCO> pList = new List <RoleMasterPOCO>();

            foreach (RoleMasterPOCO pC in pocoList)
            {
                RoleMasterPOCO pOCO = new RoleMasterPOCO();
                pOCO.RoleId   = pC.RoleId;
                pOCO.RoleName = pC.RoleName;
                //pOCO.CreatedBy = pC.CreatedBy;
                //pOCO.ModifiedBy = pC.ModifiedBy;

                pList.Add(pOCO);
            }

            var data = pList;

            return(Json(new { draw = draw, recordsFiltered = totalrecords, recordsTotal = totalrecords, data = data }, JsonRequestBehavior.AllowGet));
        }