Пример #1
0
        /// <summary>
        ///  查询导师
        /// </summary>
        /// <param name="text"></param>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public JsonResult GetYogis(string text, int page = 1, int size = 10)
        {
            YogisModelsServiceClient      client = new YogisModelsServiceClient();
            PageResult <ViewClassTeacher> pr     = new PageResult <ViewClassTeacher>();
            int records = 0;
            List <ViewYogisModels> yogis = client.GetYogisModelsList(text, 2, 0, "", page, size, out records);

            pr.Objects = (from y in yogis
                          select new ViewClassTeacher()
            {
                TeacherId = y.YID,
                Country = (y.Nationality == "" ? CommonInfo.CountryZHID.ToString() : y.Nationality),
                Name = (y.RealName ?? ""),
                Gender = (y.Gender == 0 ? "女" : "男"),
                YogaSystem = (string.IsNullOrEmpty(y.YogaTypeid) ? "0" : y.YogaTypeid),
                Info = y.GudWords,
                Avatar = y.DisplayImg
            }).ToList();
            pr.Code        = 0;
            pr.Index       = page;
            pr.PageSize    = size;
            pr.RecordCount = records;
            YogaDicItemServiceClient dicClient = new YogaDicItemServiceClient();

            foreach (ViewClassTeacher item in pr.Objects)
            {
                if (item.Country != null && item.Country != "0")
                {
                    item.Country = dicClient.GetById(int.Parse(item.Country)).ItemName;
                }
                else
                {
                    item.Country = "";
                }
                if (item.YogaSystem != "0")
                {
                    List <ViewYogaDicItem> systems = dicClient.GetSelectList(item.YogaSystem);
                    item.YogaSystem = "";
                    foreach (ViewYogaDicItem system in systems)
                    {
                        item.YogaSystem += system.ItemName + ",";
                    }
                    item.YogaSystem = item.YogaSystem.Replace(',', ' ');
                }
                else
                {
                    item.YogaSystem = "";
                }
            }
            return(Json(pr, JsonRequestBehavior.AllowGet));
        }