Ejemplo n.º 1
0
 public ActionResult Add(PermissionAddModel model)
 {
     PmService.AddNew(model.Name, model.Description);
     return(Json(new AjaxResult {
         Status = "ok"
     }));
 }
Ejemplo n.º 2
0
        public async Task <IResultModel> Add(PermissionAddModel model)
        {
            var list = new List <Permission>();

            foreach (var action in model.Actions)
            {
                var entity = new Permission
                {
                    Name       = $"{model.ControllerName}-{action.Value}",
                    ModuleCode = model.ModuleCode.ToLower(),
                    Controller = model.Controller.ToLower(),
                    Action     = action.Key.ToLower(),
                    CreatedBy  = _loginInfo.AccountId
                };

                if (await _permissionRepository.Exists(entity))
                {
                    return(ResultModel.Failed($"{action}操作已存在~"));
                }

                list.Add(entity);
            }

            var result = await _permissionRepository.AddAsync(list);

            return(ResultModel.Result(result));
        }
Ejemplo n.º 3
0
 public async Task <IResultModel> Add(PermissionAddModel model)
 {
     if (!model.Actions.Any())
     {
         return(ResultModel.Failed("请选择操作"));
     }
     return(await _service.Add(model));
 }
Ejemplo n.º 4
0
        public async Task <IResultModel> Add(PermissionAddModel model)
        {
            if (await _repository.ExistsAsync(m => m.PermissionCode == model.PermissionCode && m.IsDel == false))
            {
                return(ResultModel.HasExists);
            }

            var entity = _mapper.Map <PermissionEntity>(model);
            var result = await _repository.InsertAsync(entity);

            return(ResultModel.Result(result));
        }
Ejemplo n.º 5
0
 public ActionResult Add(PermissionAddModel model)
 {
     if (!ModelState.IsValid)
     {
         return(Json(new AjaxResult {
             Status = "error", ErrorMsg = MVCHelper.GetValidMsg(ModelState)
         }));
     }
     PerSer.AddPermission(model.Name, model.Description);
     return(Json(new AjaxResult {
         Status = "ok"
     }));
 }
Ejemplo n.º 6
0
        public ActionResult Add(PermissionAddModel permissionAdd)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new AjaxResult
                {
                    Status = "error",
                    Msg = Web.Common.WebCommonHelper.GetValidMsg(ModelState)
                }));
            }

            PermService.AddNewPermission(permissionAdd.Name, permissionAdd.Description);
            return(Json(new AjaxResult {
                Status = "ok"
            }));
        }
Ejemplo n.º 7
0
 public Task <IResultModel> Add(PermissionAddModel model)
 {
     return(_service.Add(model));
 }