Ejemplo n.º 1
0
        public ActionResult GetEmployee()
        {
            try
            {
                int      pageIndex = Convert.ToInt32(Request.QueryString["page"]);
                int      pageSize  = Convert.ToInt32(Request.QueryString["limit"]);
                string   branchIds = Request.QueryString["id"];
                string[] _ids      = branchIds.Split(',');
                int[]    ids       = Array.ConvertAll <string, int>(_ids, id =>
                {
                    return(int.Parse(id));
                });
                EmployeeBLL     eBll       = new EmployeeBLL();
                int             rows       = 0;
                int             totalPages = 0;
                List <Employee> list       = eBll.LoadPagedEntitys(pageIndex, pageSize, out rows, out totalPages, t => ids.Contains(t.branchId), true, t => t.Id);
                if (list != null && list.Count > 0)
                {
                    List <Branch> branchList = new BranchBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        branchList.ForEach(y =>
                        {
                            if (t.branchId == y.Id)
                            {
                                t.branchName = y.branchName;
                            }
                        });
                    });
                    List <Role> roleList = new RoleBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        roleList.ForEach(y =>
                        {
                            if (t.roleId == y.Id)
                            {
                                t.roleName = y.roleName;
                            }
                        });
                    });
                    List <Position> positionList = new PositionBLL().GetEntitys();
                    list.ForEach(t =>
                    {
                        positionList.ForEach(y =>
                        {
                            if (t.positionId == y.Id)
                            {
                                t.positionName = y.positionName;
                            }
                        });
                    });
                }
                string resJson = Common.Common.JsonSerialize(list);
                resJson = "{total:" + rows + ",root:" + resJson + "}";
                return(Content(resJson));
            }
            catch { }

            return(Content("{}"));
        }