Exemple #1
0
 public ActionResult UpdateUserInfo()
 {
     if (user.Id <= 0)
     {
         return(Json(new { ok = false, msg = "无效的请求" }));
     }
     else
     {
         string birthdayBeforeUpdate = user.Birthday;
         string realName             = RequestHelper.GetForm <string>("realname");
         string birthDay             = RequestHelper.GetForm <string>("birthday");
         string email = RequestHelper.GetForm <string>("email");
         if (string.IsNullOrEmpty(realName))
         {
             return(Json(new { ok = false, msg = "请填写真实姓名" }));
         }
         if (string.IsNullOrEmpty(birthDay))
         {
             return(Json(new { ok = false, msg = "请填写生日" }));
         }
         if (Convert.ToDateTime(birthDay) >= DateTime.Now)
         {
             return(Json(new { ok = false, msg = "请填写真实生日" }));
         }
         if (!string.IsNullOrEmpty(email) && !ShopCommon.CheckEmail(email))
         {
             return(Json(new { ok = false, msg = "邮箱格式错误" }));
         }
         Dictionary <string, object> dict = new Dictionary <string, object>();
         dict.Add("[RealName]", StringHelper.Substring(realName, 18, false));
         dict.Add("[Birthday]", StringHelper.Substring(birthDay, 30, false));
         dict.Add("[Email]", StringHelper.Substring(email, 30, false));
         UserBLL.UpdatePart("[usr]", dict, user.Id);
         //如果是首次填写生日信息则赠送积分20
         if (string.IsNullOrEmpty(birthdayBeforeUpdate))
         {
             UserAccountRecordInfo uar = new UserAccountRecordInfo
             {
                 RecordType = (int)AccountRecordType.Point,
                 Money      = 0,
                 Point      = 20,
                 Date       = DateTime.Now,
                 IP         = ClientHelper.IP,
                 Note       = "填写生日赠送积分",
                 UserId     = user.Id,
                 UserName   = user.UserName
             };
             if (UserAccountRecordBLL.Add(uar) > 0)
             {
                 user.PointLeft += 20;
             }
         }
         return(Json(new { ok = true }));
     }
 }