public JsonResult Register(string phone, string pwd) { //验证手机号是否合法 //验证密码是否合法 //检测数据库中是否存在这个名字 using (var db = new YearsEntities()) { var info = db.user_info.FirstOrDefault(item => item.mobile == phone); if (info != null) { return(Error("该手机号已经被注册")); } else { info = new user_info(); info.mobile = phone; info.pass = pwd; info.name = "测试账号"; db.user_info.Add(info); db.SaveChanges(); return(Success(null, "注册成功")); } } }
public int SaverChanges() { return(db.SaveChanges()); }