示例#1
0
        public IEnumerable <tbl_MCE_PrimaryLink> PrimaryLinkList(PrimaryLinkSearchPanel primaryLinkSearchPanel)
        {
            DynamicParameters param = new DynamicParameters();

            param.Add("@P_CHRACTION", "PRIMARYLINKALLSP");
            if (primaryLinkSearchPanel.vchGLinkName != null)
            {
                param.Add("@P_vchGLinkName", primaryLinkSearchPanel.vchGLinkName);
            }

            if (primaryLinkSearchPanel.vchPLinkName != null)
            {
                param.Add("@P_vchPLinkName", primaryLinkSearchPanel.vchPLinkName);
            }
            if (primaryLinkSearchPanel.vchFunctionName != null)
            {
                param.Add("@P_vchFunctionName", primaryLinkSearchPanel.vchFunctionName);
            }

            return(DapperORM.ReturnList <tbl_MCE_PrimaryLink>("SP_MCE_Primarylink_Report", param));
        }
        //This post method calls in View page thorough AJax call to bind the data in JQuery Datatable
        //Server side processing concept used to bind the data in JQuery
        public ActionResult GetPrimaryLinkForSearchPanel(PrimaryLinkSearchPanel primaryLinkSearchPanel)
        {
            //Note: Install "System.Linq.Dynamic" from Nuget Packages
            // after this just include namespace in our Controller "using System.Linq.Dynamic;".

            //Draw counter. This is used by DataTables to ensure that the Ajax returns from server-side processing requests are drawn in sequence by DataTables (Ajax requests are asynchronous and thus can return out of sequence).
            var draw = Request.Form.GetValues("draw").FirstOrDefault();

            //Paging first record indicator. This is the start point in the current data set (0 index based - i.e. 0 is the first record)
            var start = Request.Form.GetValues("start").FirstOrDefault();
            //Number of records that the table can display in the current draw.
            var length = Request.Form.GetValues("length").FirstOrDefault();

            //Find Order Column
            var sortColumn    = Request.Form.GetValues("columns[" + Request.Form.GetValues("order[0][column]").FirstOrDefault() + "][name]").FirstOrDefault();
            var sortColumnDir = Request.Form.GetValues("order[0][dir]").FirstOrDefault();

            int pageSize = length != null?Convert.ToInt32(length) : 0;

            int skip = start != null?Convert.ToInt32(start) : 0;

            int recordsTotal = 0;


            var primaryLinkList = (from a in _plinks.PrimaryLinkList(primaryLinkSearchPanel) select a);

            ////SORT
            //if (!(string.IsNullOrEmpty(sortColumn) && string.IsNullOrEmpty(sortColumnDir)))
            //{
            //    primaryLinkList = primaryLinkList.OrderBy(sortColumn + " " + sortColumnDir);
            //}

            recordsTotal = primaryLinkList.Count();
            var data = primaryLinkList.Skip(skip).Take(pageSize).ToList();

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