public ActionResult AddUser(BusinessManagerModel model) { BusinessManageEntities db = new BusinessManageEntities(); var bm = db.BusinessManager.Where(c => c.BizAbbreviation.Equals(model.BizAbbreviation, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); if (bm != null) { return Content("<script>alert('已经存在公司名称为 " + model.BizAbbreviation + " 的数据,不能重复添加');window.location.href=window.location.href;</script>"); } var manager = userService.GetManagerByUserId(model.UserId); if (manager == null || manager.UserId == 0) { return Content("<script>alert('不存在用户Id为 " + model.UserId + " 的用户,不能添加此用户');window.location.href=window.location.href;</script>"); } BusinessManager bmModel = new BusinessManager() { BizAbbreviation = model.BizAbbreviation, BizManager = model.BizManager, BizPassword = Utils.Md5(model.BizPassword), BizPhone = model.BizPhone, BusManager = model.BusManager, BusPhone = model.BusPhone, Categories = model.Categories, CreatedTime = model.CreatedTime, Deposit = model.Deposit, EndTime = model.EndTime, UserId = model.UserId }; db.BusinessManager.Add(bmModel); db.SaveChanges(); return Content("<script>alert('添加用户 " + model.BizAbbreviation + " 的数据成功');window.location.href=window.location.href;</script>"); }
public ActionResult ChangePassword(PasswordModel model) { using (BusinessManageEntities db = new BusinessManageEntities()) { int userId = (int)Session[CurrentUser]; var bm = db.BusinessManager.Where(c => c.UserId == userId).FirstOrDefault(); bm.BizPassword = Utils.Md5(model.NewPassword); db.SaveChanges(); } //return Content("<script>base.AlertTip('修改密码成功');window.location.href='/user/login';</script>"); return Json(new { Message = "修改密码成功", BackUrl = "/user/login" }, JsonRequestBehavior.AllowGet); }