예제 #1
0
        /// <summary>
        /// 添加或编辑用户信息界面。
        /// </summary>
        /// <param name="id">用户编号</param>
        /// <returns>执行结果</returns>
        public ActionResult CreateOrUpdate(string id)
        {
            var model = new CreateOrUpdateVM
            {
                User = this.UserService.GetUserById(id).Data
            };

            if (model.User != null)
            {
                this.ViewBag.RealPassword = model.User.Password;

                model.User.Password = PasswordReplaceString;
            }

            this.ViewBag.Roles = this.RoleService.GetRoles();
            this.ViewBag.Departments = this.OrganizationService.GetOrganizations();

            return this.View(model);
        }
예제 #2
0
        public ActionResult CreateOrUpdate(CreateOrUpdateVM vm)
        {
            vm.User.Initialize();

            if (string.IsNullOrWhiteSpace(vm.User.Id))
            {
                vm.User.Id = Guid.NewGuid().ToString();
            }

            vm.CheckValues = this.Request.Params["CheckValues"].Split(',').ToList();
            vm.User.Password = vm.User.Password == PasswordReplaceString ? this.Request.Form["RealPassword"] : vm.User.Password.Encrypt();

            var rsp = this.UserService.CreateOrUpdate(vm.User, vm.Departments, vm.Roles);

            return rsp.IsSuccess ? this.CloseDialogWithAlert("保存成功!") : this.Alert($"发生错误,错误原因:{rsp.ErrorMessage}", AlertType.Error);
        }