public GlobalPermissionForRole CheckExists(GlobalPermissionForRole permissionForRole) { if (permissionForRole.Permission != null && permissionForRole.MembershipRole != null) { return(_globalPermissionForRoleRepository.Get(permissionForRole.Permission.Id, permissionForRole.MembershipRole.Id)); } return(null); }
public GlobalPermissionForRole CheckExists(GlobalPermissionForRole permissionForRole) { if (permissionForRole.Permission != null && permissionForRole.MembershipRole != null) { return Get(permissionForRole.Permission.Id, permissionForRole.MembershipRole.Id); } return null; }
private static PermissionForRole MapGlobalPermission(GlobalPermissionForRole gp) { var pfr = new PermissionForRole { IsTicked = gp.IsTicked, MembershipRole = gp.MembershipRole, Permission = gp.Permission }; return(pfr); }
public void UpdateOrCreateNew(GlobalPermissionForRole globalPermissionForRole) { // Firstly see if this exists already var permission = CheckExists(globalPermissionForRole); // if it exists then just update it if (permission != null) { permission.IsTicked = globalPermissionForRole.IsTicked; } else { Add(globalPermissionForRole); } }
public void UpdatePermission(AjaxEditPermissionViewModel ajaxEditPermissionViewModel) { using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { try { if (Request.IsAjaxRequest()) { if (ajaxEditPermissionViewModel.Category == Guid.Empty) { // If category is empty guid then this is a global permission var gpr = new GlobalPermissionForRole { MembershipRole = _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole), Permission = _permissionService.Get(ajaxEditPermissionViewModel.Permission), IsTicked = ajaxEditPermissionViewModel.HasPermission }; _globalPermissionForRoleService.UpdateOrCreateNew(gpr); } else { // We have a category so it's a category permission var mappedItem = new CategoryPermissionForRole { Category = _categoryService.Get(ajaxEditPermissionViewModel.Category), MembershipRole = _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole), Permission = _permissionService.Get(ajaxEditPermissionViewModel.Permission), IsTicked = ajaxEditPermissionViewModel.HasPermission }; _categoryPermissionForRoleService.UpdateOrCreateNew(mappedItem); } } unitOfWork.Commit(); } catch (Exception ex) { unitOfWork.Rollback(); LoggingService.Error(ex); throw; } } }
public void UpdatePermission(AjaxEditPermissionViewModel ajaxEditPermissionViewModel) { try { if (Request.IsAjaxRequest()) { if (ajaxEditPermissionViewModel.Group == Guid.Empty) { // If Group is empty guid then this is a global permission var gpr = new GlobalPermissionForRole { MembershipRole = _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole), Permission = _permissionService.Get(ajaxEditPermissionViewModel.Permission), IsTicked = ajaxEditPermissionViewModel.HasPermission }; _globalPermissionForRoleService.UpdateOrCreateNew(gpr); } else { // We have a Group so it's a Group permission var mappedItem = new GroupPermissionForRole { Group = _groupService.Get(ajaxEditPermissionViewModel.Group), MembershipRole = _roleService.GetRole(ajaxEditPermissionViewModel.MembershipRole), Permission = _permissionService.Get(ajaxEditPermissionViewModel.Permission), IsTicked = ajaxEditPermissionViewModel.HasPermission }; _groupPermissionForRoleService.UpdateOrCreateNew(mappedItem); } } Context.SaveChanges(); } catch (Exception ex) { Context.RollBack(); LoggingService.Error(ex); throw; } }
public void Delete(GlobalPermissionForRole permissionForRole) { _globalPermissionForRoleRepository.Delete(permissionForRole); }
public void Add(GlobalPermissionForRole permissionForRole) { _globalPermissionForRoleRepository.Add(permissionForRole); }
public void Delete(GlobalPermissionForRole permissionForRole) { _context.GlobalPermissionForRole.Remove(permissionForRole); }
public GlobalPermissionForRole Add(GlobalPermissionForRole permissionForRole) { return(_context.GlobalPermissionForRole.Add(permissionForRole)); }
public void Add(GlobalPermissionForRole permissionForRole) { _context.GlobalPermissionForRole.Add(permissionForRole); }
public GlobalPermissionForRole Add(GlobalPermissionForRole permissionForRole) { return _context.GlobalPermissionForRole.Add(permissionForRole); }