コード例 #1
0
 public async Task <IActionResult> EditPurview(IFormCollection form)
 {
     if (ModelState.IsValid)
     {
         var model = new SysRoleModuleViewModel();
         model.RoleId = form["RoleId"];
         var arr = form.Keys.ToList();
         for (int i = 0; i < form.Count; i++)
         {
             if (arr[i] != "__RequestVerificationToken" && arr[i] != "RoleId")
             {
                 var      module  = new SysModuleBase();
                 string   s       = form[arr[i]];
                 string[] str_num = s.Split(',');
                 long     a       = str_num.Select(t => long.Parse(t)).Sum();
                 module.ControllerName = arr[i];
                 module.PurviewSum     = a;
                 model.ModuleBases.Add(module);
             }
         }
         await _rolesService.SaveRoleModule(model);
     }
     return(RedirectToAction("EditPurview", new { Id = form["RoleId"] }));
 }