Ejemplo n.º 1
0
 public ActionResult CheckPhoneExist(string phone, long?adminID)
 {
     if (!string.IsNullOrEmpty(phone))
     {
         AdminUserDTO userModel = AdminUserService.IsExitTelePhone(phone);
         bool         isOK      = false;
         //如果没有给adminID,则说明是“插入”,只要检查是不是存在这个手机号
         if (adminID == null)
         {
             isOK = (userModel == null);
         }
         else//如果有userId,则说明是修改,则要把自己排除在外
         {
             isOK = (userModel == null || userModel.Id == adminID);
         }
         return(Json(new AjaxResult {
             Status = isOK ? "ok" : "exists"
         }));
     }
     else
     {
         return(Json(new AjaxResult()
         {
             Status = "no"
         }));
     }
 }
Ejemplo n.º 2
0
 public ActionResult AddAdmin(AddAdminModel model)
 {
     if (ModelState.IsValid)
     {
         //1服务端也也要校验手机是否被真正的注册过
         AdminUserDTO userModel = AdminUserService.IsExitTelePhone(model.PhoneNum);
         if (userModel == null)
         {
             long adminUserID = AdminUserService.AddAdminUser(model.Name, model.PhoneNum, model.Pwd);
             RoleService.AddRoleIds(adminUserID, model.RoleIds);//添加用户角色的对应关系,此处应该启用事物
             return(Json(new AjaxResult()
             {
                 Status = "ok"
             }));
         }
         else
         {
             return(Json(new AjaxResult()
             {
                 Status = "exists"
             }));
         }
     }
     else
     {
         string errorMsg = CommonHelper.GetValidMsg(ModelState);//验证出错时候具体的错误信息
         return(Json(new AjaxResult()
         {
             Status = "no", ErrorMsg = errorMsg
         }));
     }
 }