예제 #1
0
 /// <summary>
 /// 根据中文名生成拼音英文名
 /// </summary>
 /// <param name="namecn"></param>
 /// <returns></returns>
 public ActionResult AutoUserName(string namecn = "")
 {
     if (!string.IsNullOrEmpty(namecn))
     {
         string first       = PinyinHelper.sub(namecn, 1);
         string firstpin    = PinyinHelper.ToPinYin(first);
         int    num         = namecn.Length;
         string other       = namecn.Substring(1);
         string otherpin    = PinyinHelper.ToPinYin(other);
         string finalpinyin = otherpin + " " + firstpin;
         return(Json(new { status = 1, data = finalpinyin }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { status = 1, data = "" }, JsonRequestBehavior.AllowGet));
 }