예제 #1
0
        public ActionResult Add(UserAddModel model)
        {
            if (!ModelState.IsValid)
            {
                string msg = mvchelper.GetValiMsg(ModelState);
                return(Json(new AjaxResult {
                    status = "error", errorMsg = msg
                }));
            }
            //服务器端的校验必不可少
            bool exists = UserSvc.GetByPhoneNum(model.phonenum) != null;

            if (exists)
            {
                return(Json(new AjaxResult
                {
                    status = "error",
                    errorMsg = "手机号已经存在"
                }));
            }

            long userId = UserSvc.AddUser(model.account, model.nickname,
                                          model.phonenum, model.gender, model.password, model.email);

            UserRoleSvc.AddUserRole(userId, model.RoleIds);
            //roleService.AddRoleIds(userId, model.RoleIds);
            return(Json(new AjaxResult {
                status = "ok"
            }));
        }
예제 #2
0
 public ActionResult Edit(UserEditModel model)
 {
     UserSvc.UpdateUser(model.id, model.nickname, model.phonenum
                        , model.gender, model.password, model.email);
     UserRoleSvc.AddUserRole(model.id, model.RoleIds);
     return(Json(new AjaxResult {
         status = "ok"
     }));
 }