Ejemplo n.º 1
0
        public ActionResult SearchRole(RolePager pager)
        {
            var service = Container.GetService <IRoleService>();
            var size    = Convert.ToInt32(pager.pageSize);
            var idx     = Convert.ToInt32(pager.pageIndex);

            var where = new StringBuilder(" where 1=1 ");
            if (!string.IsNullOrWhiteSpace(pager.Name))
            {
                where.AppendLine("and C_Name like '%" + pager.Name + "%'");
            }
            if (!string.IsNullOrWhiteSpace(pager.DateFrom))
            {
                where.AppendLine("and C_CreatedDate>'" + pager.DateFrom + "' ");
            }
            if (!string.IsNullOrWhiteSpace(pager.DateTo))
            {
                where.AppendLine("and C_CreatedDate<'" + pager.DateTo + "' ");
            }
            var sql   = @"SELECT TOP 1000 t1.[keyid]
                          ,[C_Name]
                          ,ParentName
                          ,[C_ParentRole]
                          ,[C_CreatedDate]
                          ,[C_UpdatedDate]
                      FROM [DATA_MANAGE].[dbo].[tbl_Role] as t1
                      left join (select keyid, C_Name as ParentName from tbl_Role) as t2
                      on t1.C_ParentRole=t2.keyid";
            var roles = service.GetModelsByPage <RoleDto>(size, idx, sql + where);

            var rolegrid = new RoleGrid();

            rolegrid.rows  = RoleInfo.ConvertToRoleInfos(roles);
            rolegrid.total = service.GetTableCount(where.ToString());
            return(Json(rolegrid));
        }