Example #1
0
        public ActionResult Edit(CustomPermissionsModel model)
        {
            if (ModelState.IsValid)
            {
                if (customPermissionsService.AlreadyExists(model.Name, model.MenuId, model.Id))
                {
                    ModelState.AddModelError("Name", "自定义权限名重复");
                }
                else
                {
                    var customPermission = customPermissionsService.Get(model.Id);
                    //忽略更新
                    model.CreateDate = customPermission.CreateDate;
                    model.MenuId     = customPermission.MenuId;

                    customPermission = model.ToEntity(customPermission);
                    customPermissionsService.Modify(customPermission);
                    return(Json(new AjaxResult()
                    {
                        Result = Result.Success
                    }));
                }
            }
            return(View(model));
        }
Example #2
0
        public ActionResult Create(Guid?id)
        {
            CustomPermissionsModel model = new CustomPermissionsModel();

            if (id.HasValue)
            {
                model.MenuId = id;
            }
            return(View(model));
        }
Example #3
0
 public ActionResult Create(CustomPermissionsModel model)
 {
     if (ModelState.IsValid)
     {
         if (customPermissionsService.AlreadyExists(model.Name, model.MenuId, Guid.Empty))
         {
             ModelState.AddModelError("Name", "权限名重复");
         }
         else
         {
             customPermissionsService.Add(model.ToEntity());
             return(Json(new AjaxResult()
             {
                 Result = Result.Success
             }));
         }
     }
     return(View(model));
 }
Example #4
0
 public static CustomPermissions ToEntity(this CustomPermissionsModel model, CustomPermissions destination)
 {
     return(model.MapTo(destination));
 }
Example #5
0
 public static CustomPermissions ToEntity(this CustomPermissionsModel model)
 {
     return(Mapper.Map <CustomPermissionsModel, CustomPermissions>(model));
 }