Exemplo n.º 1
0
        public ActionResult UpdateRequirement(RequirementClone info)
        {
            info.HightUl = info.HightUl == "不限" ? "0" : info.HightUl.Substring(0, 3);
            info.HightLl = info.HightLl == "不限" ? "0" : info.HightLl.Substring(0, 3);
            info.AgeUl = info.AgeUl == "不限" ? "0" : info.AgeUl.Substring(0, 2);
            info.MonthlyIncomeLl = info.MonthlyIncomeLl == "不限" ? "0" : info.MonthlyIncomeLl.Split('元')[0];
            info.MonthlyIncomeUl = info.MonthlyIncomeUl == "不限" ? "0" : info.MonthlyIncomeUl.Split('元')[0];
            info.Education = info.Education == "不限" ? "" : info.Education;

            var id = CheckValid();
            if (info.ResidenceCity == "选择城市")
            {
                info.ResidenceCity = "";
            }
            var requirement = new Requirement
                {
                    HightLl = info.HightLl == "0" ? 0 : Convert.ToInt16(info.HightLl.Substring(0, 3)),
                    HightUl = Convert.ToInt16(info.HightUl),
                    AgeLl = Convert.ToInt16(info.AgeLl.Substring(0, 2)),
                    AgeUl = Convert.ToInt16(info.AgeUl),
                    Education = info.Education,
                    MonthlyIncomeLl = Convert.ToInt16(info.MonthlyIncomeLl),
                    MonthlyIncomeUl = Convert.ToInt16(info.MonthlyIncomeUl),
                    ResidenceProvince = info.ResidenceProvince,
                    ResidenceCity = info.ResidenceCity,
                    UserId = id

                };
            PrivateDb.UpdateRequirement(requirement);
            info.UserId = id;
            return Json(requirement);
        }
Exemplo n.º 2
0
 public string GetRequirStr(Requirement re)
 {
     var sb = new StringBuilder("我正在看:<span>");
     if (re != null)
     {
         //居住地
         if (re.ResidenceProvince != null)
         {
             sb.Append(re.ResidenceProvince + re.ResidenceCity + ",");
         }
         //年龄
         if (re.AgeLl != 0)
         {
             sb.Append(re.AgeUl != 0 ? re.AgeLl + "到" + re.AgeUl + "岁," : re.AgeLl + "岁以上,");
         }
         //身高
         if (re.HightLl != 0)
         {
             sb.Append(re.HightUl == 0 ? re.HightLl + "厘米以上" : re.HightLl + "到" + re.HightUl + "厘米");
         }
     }
     else
     {
         sb.Append("18岁以上");
     }
     sb.Append(GetMyself().User.Sex == "man" ? " 的女生</span>" : "的男生</span>");
     return sb.ToString();
 }
Exemplo n.º 3
0
        public bool PartMathUser(Requirement condition, UninUser biguser)
        {
            var residenceflag = false;
            var ageflag = false;
            var hightflag = false;

            if (string.IsNullOrEmpty(condition.ResidenceCity)||(biguser.BaseInfo.ResidenceCity != null && biguser.BaseInfo.ResidenceCity.Contains(condition.ResidenceCity)) )
            {
                residenceflag = true;
            }

            //年龄
            if ((condition.AgeLl == 0 || (biguser.User.Age != 0 && biguser.User.Age <= condition.AgeUl && biguser.User.Age >= condition.AgeLl))//agelow 要比 ageup 大
                || (condition.AgeUl == 0 && biguser.User.Age >= condition.AgeLl))
            {
                ageflag = true;
            }

            //身高
            int hight = Convert.ToInt32(biguser.BaseInfo.Height.Split('厘')[0]);
            if (condition.HightLl == 0 || (biguser.BaseInfo.Height != null && ((hight <= condition.HightUl && hight >= condition.HightLl && condition.HightUl != 0)
                || (condition.HightUl == 0 && hight >= condition.HightLl))))
            {
                hightflag = true;
            }
            return hightflag && residenceflag && ageflag;
        }
Exemplo n.º 4
0
        /// <summary>
        /// first和second比较,second为主体  到时候要改成返回对象 
        /// </summary>
        /// <param name="user">被比较者的Id</param>
        /// <param name="second">比较着的资料</param>
        /// <returns></returns>
        private double TomeRate(UninUser user, Requirement second)
        {
            var tomeInts = GetTomeInts(user, second);

            return (double)tomeInts.Sum()/ 5;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 两者需求匹配度
        /// </summary>
        /// <param name="user"></param>
        /// <param name="second"></param>
        /// <returns></returns>
        public int[] GetTomeInts(UninUser user, Requirement second)
        {
            var firstage = user.User.Age;
            var high =string.IsNullOrEmpty(user.BaseInfo.Height)?0:Convert.ToInt16(user.BaseInfo.Height.Split('厘')[0]);

            var tomeInts = new int[5];

            //没有年龄限制,或者在second的要求范围内,Ageui=0表示是没有上限。
            if (second.AgeLl == 0 || (second.AgeLl <= firstage && (second.AgeUl == 0 || second.AgeUl >= firstage)))
            {
                tomeInts[0] = 1;
            }

            // 地方
            if (string.IsNullOrEmpty(second.ResidenceProvince) ||
                (second.ResidenceProvince == user.BaseInfo.ResidenceProvince &&
                 (second.ResidenceCity == user.BaseInfo.ResidenceCity || string.IsNullOrEmpty(second.ResidenceCity))))
            {
                tomeInts[1] = 1;
            }
            //身高
            if (second.HightLl == 0 || (second.HightLl <= high && (second.HightUl == 0 || second.HightUl >= high))||high==0)
            {
                tomeInts[2] = 1;
            }

            //学历 null 大专 本科 硕士 博士 /不限 大专以下 大专及以上  本科+  硕士+ 博士+
            if (string.IsNullOrEmpty(second.Education) ||
                (ChangEducationToNum(second.Education) <= ChangEducationToNum(user.BaseInfo.Education) && !string.IsNullOrEmpty(user.BaseInfo.Education)))
            {
                tomeInts[3] = 1;
            }

            //月收入 先算出中间值。
            int mm=0;
            if (!string.IsNullOrEmpty(user.BaseInfo.MonthlyIncome))
            {
                mm = user.BaseInfo.MonthlyIncome == "3000元以下" ? 2500 : Convert.ToInt16(user.BaseInfo.MonthlyIncome.Split('-')[0]) + 500;
            }

            if (second.MonthlyIncomeLl == 0 ||
                (second.MonthlyIncomeLl < mm || (second.MonthlyIncomeUl == 0 || second.MonthlyIncomeUl > mm)) || mm==0)
            {
                tomeInts[4] = 1;
            }
            return tomeInts;
        }