Esempio n. 1
0
 public JsonResult InsertRolePermissions(string rolePermissionViewodel)
 {
     RolePermissionsViewModel PermissionViewodel = JsonConvert.DeserializeObject<RolePermissionsViewModel>(rolePermissionViewodel);
     InsertRolePermissionsResponse response = roleService.InsertRolePermissions(new InsertRolePermissionsRequest()
     {
         rolePermissionsViewModel = PermissionViewodel
     });
     if (response.Exception == null)
     {
         int accountId = this.Identity.ToAccountID();
         cachingService.AddUserPermissions(accountId);
     }
     return Json(new
     {
         success = true,
         response = ""
     }, JsonRequestBehavior.AllowGet);
 }
Esempio n. 2
0
        public InsertRolePermissionsResponse InsertRolePermissions(InsertRolePermissionsRequest request)
        {
            Logger.Current.Verbose("Request to insert role permissions");
            InsertRolePermissionsResponse response = new InsertRolePermissionsResponse();
            var rolePermissionsViewModel           = request.rolePermissionsViewModel;

            if (rolePermissionsViewModel != null)
            {
                List <ModuleViewModel> modulesViewModel = rolePermissionsViewModel.Modules.ToList();
                List <ModuleViewModel> subModules       = new List <ModuleViewModel>();
                foreach (var viewModel in modulesViewModel)
                {
                    if (viewModel.SubModules.Any())
                    {
                        subModules.AddRange(viewModel.SubModules);
                    }
                }
                modulesViewModel.AddRange(subModules);
                List <ModuleViewModel> modules       = modulesViewModel.Where(s => s.IsSelected == true).GroupBy(s => s.ModuleId).Select(y => y.First()).ToList();
                List <byte>            domainModules = modules.Select(s => s.ModuleId).ToList(); //ConvertToModule(modules);
                roleRepository.InsertRolePermissions(rolePermissionsViewModel.SelectedRole, domainModules);
            }
            return(response);
        }