예제 #1
0
        public IActionResult Index(string username, string password, string txpassword, string realname, string parent_id, string email)
        {
            try
            {
                username = Tool.GetSafeSQL(username);
                email    = Tool.GetSafeSQL(email);
                int x = udal.CalcCount($"username='******'");
                if (x > 0)
                {
                    return(Json(new { code = 1, msg = "账号已存在" }));
                }
                int    i          = 0;
                string parentname = "";
                string parentpath = "";
                if (int.TryParse(parent_id, out i))
                {
                    Model.Userinfo pu = udal.GetModel(i);
                    if (pu == null)
                    {
                        return(Json(new { code = 1, msg = "没有该推荐人" }));
                    }
                    else
                    {
                        parentname = pu.username;
                        parentpath = pu.parentpath + pu.id + ",";
                    }
                }
                if (udal.CalcCount($"email='{email}'") > 0)
                {
                    return(Json(new { code = 1, msg = "邮箱重复" }));
                }

                Model.Userinfo u = new Model.Userinfo()
                {
                    parentid   = i,
                    email      = email,
                    username   = username,
                    password   = Tool.MD5Hash(username + password + "caipiao"),
                    realname   = realname,
                    parentpath = parentpath,
                    parentname = parentname,
                };
                int userid = udal.Add(u);
                u.id = userid;
                HttpContext.Session.SetInt32("caipiao_uerid", u.id);
                return(Json(new { code = 0, msg = "注册成功" }));
            }
            catch (Exception ex)
            {
                return(Json(new { code = 1, msg = "error: " + ex.Message }));
            }
        }
예제 #2
0
        /// <summary>
        /// 取总记录数
        /// </summary>
        /// <returns></returns>
        public ActionResult GetTotalCount(string key, string start, string end, string cabh, string email)
        {
            int totalcount = dal.CalcCount(GetCond(key, start, end, cabh, email));

            return(Content(totalcount.ToString()));
        }