Ejemplo n.º 1
0
 public ActionResult EditShadow(ShadowModel model, int Id = 0)
 {
     if (Id == 0) PageNotFound();
     ModelState.Remove("UserName");
     ModelState.Remove("Password");
     JsonResultModel result = new JsonResultModel();
     if (!(result.IsSuccess = ModelState.IsValid))
     {
         result.Message = ModelState.ToErrorString();
     }
     else
     {
         var user = UserManager.GetUser(Id);
         if (user == null || user.ParentId != CurrentUser.UserId)
             throw new NoPermissionException("Update Shadow");
         if (result.IsSuccess = EncryptHelper.Equal(model.YourPassword, CurrentUser.UserInfo.Password))
         {
             user.UserInfo.Name = model.Name;
             user.UserInfo.State = model.State;
             user.UserInfo.Email = model.Email;
             UserManager.UpdateShadow(user, model.AuthActions);
             ActionLogger.Log(CurrentUser, user, LogResources.EditShadow, LogResources.GetEditShadow(user.UserName));
             result.Message = Resource.Success;
         }
         else
             result.Message = Resource.PasswordError;
     }
     return Json(result);
 }
Ejemplo n.º 2
0
 public ActionResult AddShadow(ShadowModel model)
 {
     JsonResultModel result = new JsonResultModel();
     if (!(result.IsSuccess = ModelState.IsValid))
     {
         result.Message = ModelState.ToErrorString();
     }
     else
     {
         if (result.IsSuccess = EncryptHelper.Equal(model.YourPassword, CurrentUser.UserInfo.Password))
         {
             var user = model.ToUser();
             user.ParentId = CurrentUser.UserId;
             UserManager.AddShadow(user, model.AuthActions);
             ActionLogger.Log(CurrentUser, user, LogResources.AddShadow, LogResources.GetAddShadow(model.UserName));
             result.Message = Resource.Success;
             result.Model = model;
         }
         else
             result.Message = Resource.PasswordError;
     }
     return Json(result);
 }