public ActionResult Reg(User user) { int localZont = 0; int.TryParse(Request.Form["localZone"], out localZont); //创建语言服务 LanguageService languageservice = LanguageService.GetInstance(); //获取所有语言信息 IList <Language> languages = languageservice.GetList(); ViewData["languages"] = languages; User regUser = userService.GetUserByName(user.username); if (regUser == null) { int uid = 0; user.password = EncryptUtil.EncryptDES(user.password, EncryptUtil.defaultKey); uid = userService.save(user); //注册用户默认管理员权限 UserRoleService.GetInstance().Insert(new UserRole() { userId = uid, roleId = 3 }); TempData[ComConst.User] = user; UserUtil.ResetLogin(user); //记录登录记录 string ip = WebUtil.getClientIp(Request); LoginRecordService.GetInstance().Save(user.id, user.username, ip, localZont); return(RedirectToAction("success", "auth")); } else { ModelState.AddModelError("UserName", Resources.SunResource.REG_USERNAME_ERROR_INFO); return(View()); } }
public ActionResult Save(User user) { if (user.id > 0) { UserService userService = UserService.GetInstance(); int languageId = userService.GetLanguageIdById(UserUtil.getCurUser().id); //创建语言服务 LanguageService languageservice = LanguageService.GetInstance(); //获取所有语言信息 Language language = languageservice.GetNameByLanguageId(languageId); IList <Language> languages = languageservice.GetList(); ViewData["lang"] = language; ViewData["languages"] = languages; UserService userservice = UserService.GetInstance(); ViewData["langs"] = LanguageService.GetInstance().GetList(); base.GetLanguage(); IList <CommonInfo> currencies = CommonInfoService.GetInstance().GetList(new CommonInfo() { pid = CommonInfo.Currency }); IList <SelectListItem> items = new List <SelectListItem>(); foreach (CommonInfo currency in currencies) { items.Add(new SelectListItem() { Text = string.Format("{0}:{1}", currency.code, currency.name), Value = currency.code }); } ViewData["currencies"] = items; return(RedirectToAction("addplant", "newregister")); } else { int localZont = 0; int.TryParse(Request.Form["localZone"], out localZont); //创建语言服务 LanguageService languageservice = LanguageService.GetInstance(); //获取所有语言信息 IList <Language> languages = languageservice.GetList(); ViewData["languages"] = languages; User regUser = UserService.GetInstance().GetUserByName(user.username); if (regUser == null) { int uid = 0; user.password = EncryptUtil.EncryptDES(user.password, EncryptUtil.defaultKey); uid = UserService.GetInstance().save(user); //注册用户默认管理员权限 UserRoleService.GetInstance().Insert(new UserRole() { userId = uid, roleId = 3 }); TempData[ComConst.User] = user; UserUtil.ResetLogin(user); //记录登录记录 string ip = WebUtil.getClientIp(Request); LoginRecordService.GetInstance().Save(user.id, user.username, ip, localZont); return(RedirectToAction("addplant", "newregister")); } else { ModelState.AddModelError("UserName", Resources.SunResource.REG_USERNAME_ERROR_INFO); return(View("register")); } } }