Esempio n. 1
0
        /// <summary>
        /// 查询列表(带分页)
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public Response <List <DoctorMemberDTO> > GetList(DoctorMemberCondition condition)
        {
            using (var db = new DBEntities())
            {
                var query = from item in db.DoctorMembers
                            join doctor in db.Doctors on item.DoctorID equals doctor.DoctorID
                            join member in db.UserMembers on item.MemberID equals member.MemberID
                            //join map in db.UserMemberMaps on member.MemberID equals map.MemberID
                            //join user in db.Users on map.UserID equals user.UserID
                            orderby item.ModifyTime, item.CreateTime descending
                where item.IsDeleted == false && member.IsDeleted == false &&
                doctor.DoctorID == condition.UserID                //&& map.IsDeleted == false
                    select new DoctorMemberDTO
                {
                    DoctorMemberID = item.DoctorMemberID,
                    DoctorID       = item.DoctorID,
                    MemberID       = item.MemberID,
                    MemberName     = member.MemberName,
                    Birthday       = member.Birthday,
                    Gender         = member.Gender,
                    Mobile         = member.Mobile
                };
                //动态查询条件
                if (!string.IsNullOrEmpty(condition.Keyword))
                {
                    query = query.Where(i => i.MemberName.Contains(condition.Keyword));
                }
                //分页
                int total = 0;
                var page  = query.Pager(out total, condition.CurrentPage, condition.PageSize);

                //从字典中取名称
                if (page != null && page.Count > 0)
                {
                    SysDictService dictService = new SysDictService();
                    page.ForEach(i =>
                    {
                        i.GenderName = dictService.GetDictName(EnumDictType.UserGender, ((int)i.Gender).ToString());
                    });
                }

                var result = new Response <List <DoctorMemberDTO> >()
                {
                    Data  = page,
                    Total = total
                };
                return(result);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 我的患者(下拉框)
        /// </summary>
        /// <returns></returns>
        public Response <List <DoctorMemberDTO> > GetMyMemberDDL(DoctorMemberCondition condition)
        {
            var result = new Response <List <DoctorMemberDTO> >();

            using (var db = new DBEntities())
            {
                var query = from item in db.DoctorMembers
                            join member in db.UserMembers on item.MemberID equals member.MemberID
                            //join map in db.UserMemberMaps on member.MemberID equals map.MemberID
                            //join user in db.Users on map.UserID equals user.UserID
                            orderby item.ModifyTime, item.CreateTime descending
                where item.IsDeleted == false && member.IsDeleted == false &&
                item.DoctorID == condition.DoctorID                //&& map.IsDeleted == false
                    select new DoctorMemberDTO
                {
                    MemberID   = item.MemberID,
                    MemberName = member.MemberName,
                    Gender     = member.Gender,
                    Birthday   = member.Birthday,
                    Mobile     = member.Mobile
                };
                if (!string.IsNullOrEmpty(condition.PatientName))
                {
                    query = query.Where(i => i.MemberName.Contains(condition.PatientName));
                }

                int total = 0;
                result.Data  = query.Pager(out total, condition.CurrentPage, condition.PageSize);
                result.Total = total;
            }

            if (result.Data != null)
            {
                var dictService = new SysDictService();
                result.Data.ForEach(i =>
                {
                    i.GenderName = dictService.GetDictName(EnumDictType.UserGender, ((int)i.Gender).ToString());
                });
            }
            return(result);
        }