コード例 #1
0
        /// <summary>
        /// 根据条件查找用户信息
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="tel"></param>
        /// <param name="pageInfo"></param>
        /// <returns></returns>
        public object SearchCustomersByWhere(string ids, string name, string tel, PageInfo pageInfo)
        {
            var svc          = new CommonService();
            var memberLevel  = new MemberLevelService();//12-22新增
            var customerData = context.Customers.Where(p => p.IsDeleted != 1);

            if (!name.IsNullOrTrimEmpty())
            {
                customerData = customerData.Where(p => p.FullName.Contains(name));
            }
            if (!tel.IsNullOrTrimEmpty())
            {
                customerData = customerData.Where(p => p.Tel.Contains(tel) || p.Mobile.Contains(tel));
            }
            if (ids.IsNotNullOrEmpty())
            {
                customerData = customerData.Where(p => !ids.Contains(p.Id));
            }

            var result = customerData.OrderBy(a => a.Id).Skip((pageInfo.Page - 1) * pageInfo.Rows).Take(pageInfo.Rows).ToList()
                         .Select(a => new
            {
                Id              = a.Id,
                FullName        = a.FullName + "",
                Tel             = a.Tel + "",
                Mobile          = a.Mobile + "",
                Email           = a.Email + "",
                Sex             = EnumHelper.GetDescription(((Sex)(a.Sex ?? 3))),
                CustomerType    = svc.GetDictionaryName("CustomerCategory", a.CustomerType + ""),
                Integral        = a.Integral,                                                    //12-22新增
                MemberLevelText = memberLevel.GetMemberLevelByLevelVal(a.MemberLevelValue).Title //12-22新增
            });

            return(new { total = customerData.Count(), rows = result });
        }
コード例 #2
0
        /// <summary>
        /// 根据一堆id查询客户信息
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="pageinfo"></param>
        /// <returns></returns>
        public object GetCustomerIdByIds(string ids, out int totalCount, PageInfo pageinfo)
        {
            var svc         = new CommonService();
            var memberLevel = new MemberLevelService();
            var queryData   = context.Customers.Where(p => ids.Contains(p.Id) && p.IsDeleted != 1);

            totalCount = queryData.Count();
            var result = queryData.OrderByDescending(p => p.CreatedOn).Skip((pageinfo.Page - 1) * pageinfo.Rows).Take(pageinfo.Rows).ToList()
                         .Select(a => new
            {
                Id              = a.Id,
                FullName        = a.FullName + "",
                Tel             = a.Tel + "",
                Mobile          = a.Mobile + "",
                Email           = a.Email + "",
                Sex             = EnumHelper.GetDescription(((Sex)(a.Sex ?? 3))),
                CustomerType    = svc.GetDictionaryName("CustomerCategory", a.CustomerType + ""),
                Integral        = a.Integral,
                MemberLevelText = memberLevel.GetMemberLevelByLevelVal(a.MemberLevelValue).Title
            });

            return(result);
        }