日期:2014-05-17 浏览次数:20399 次
/// <summary> /// 用户的Email地址 /// </summary> [Required(ErrorMessage = "Email必填")] [Display(Name = "Email")] [DataType(DataType.EmailAddress, ErrorMessage = "你的邮箱格式不对。\n正确的邮箱格式为'85167538@qq.com'")] [Remote("CheckEmailExists", "Account", ErrorMessage = "此邮箱己存在")] public string Email { get; set; }
/// <summary> /// 验证邮箱的唯一性 /// </summary> /// <param name="email"></param> /// <returns></returns> public JsonResult CheckEmailExists(string email) { BlogEnt db = new BlogEnt(); var result = from e in db.Users where e.Email == email.ToLower().Trim() select e; return Json(result.ToList().Count == 0, JsonRequestBehavior.AllowGet); }
public ActionResult EditUserInfo(int id) { User user = db.Users.Find(id); if (user == null ||Convert.ToInt32(Session["userid"])!=id) { return RedirectToAction("Index"); } else { ViewBag.skinid = db.Skins.OrderBy(a => a.SkinID).ToList(); return View(user); } } [HttpPost] public ActionResult EditUserInfo(User user ) { try { var u = db.Users.Find(user.UserID); UpdateModel(u); db.SaveChanges(); return RedirectToAction("Index"); } catch { ModelState.AddModelError("", "修改失败,请查看详细错误信息。"); } return View(user); }