public ActionResult App_UpdateUser(AppUser user) { JsonMessage returnJson = new JsonMessage(); using (LoveBankDBContext db = new LoveBankDBContext()) { var t_a = db.T_AppUser; AppUser entityAppUser = db.T_AppUser.Where(x=>x.ID==user.ID).FirstOrDefault(); entityAppUser.Age = user.Age; entityAppUser.Name = user.Name; entityAppUser.NickName = user.NickName; entityAppUser.Sex = user.Sex; db.Update(entityAppUser); db.SaveChanges(); returnJson.Status = true; returnJson.Info = "修改成功"; returnJson.Data = HttpContext.Error; return Json(returnJson); } returnJson.Status = false; returnJson.Info = "登录失败,系统异常"; returnJson.Data = HttpContext.Error; return Json(returnJson); }
public ActionResult AppUserReg(AppUser user, string code) { if (user == null || string.IsNullOrEmpty(code) || user.Type == null || string.IsNullOrEmpty(user.PassWord) && string.IsNullOrEmpty(user.Phone)) { Json("注册账号、密码、验证码和用户类型是必填项"); } user.PassWord = user.PassWord.Hash();//hash user.AddTime = DateTime.Now; user.LastLoginTime = DateTime.Now; JsonMessage returnJson = new JsonMessage(); using (LoveBankDBContext db = new LoveBankDBContext()) { try { if (db.T_AppUser.Count(x => x.Phone == user.Phone) > 0) { returnJson.Info = "该手机号已经存在,不能注册"; returnJson.Status = false; return Json(returnJson); } DateTime codeOutTime = DateTime.Now.AddMinutes(-10); int existCount = db.T_SMS.Count(x => x.Phone == user.Phone.Trim() && x.VCode == code.Trim() && x.Class == SmsClass.注册验证码 && x.AddTime > codeOutTime); if (existCount == 0) { returnJson.Info = "注册验证码失效,请重新获取"; returnJson.Status = false; return Json(returnJson); } db.Add(user); db.SaveChanges(); returnJson.Status = true; returnJson.Info = "注册成功"; returnJson.Data = user; return Json(returnJson); } catch (Exception ex) { returnJson.Info = ex.Message; returnJson.Status = false; return Json(returnJson); } } }