/// <summary> /// Creates a new report role /// </summary> /// <param name="configuration">The role configuration</param> /// <returns>The role created</returns> public ReportRole CreateRole ( ReportRoleConfiguration configuration ) { var role = new ReportRole ( configuration ); _roleRepository.AddRole(role); _unitOfWork.SaveChanges(); return(role); }
/// <summary> /// Auto registers multiple report roles /// </summary> /// <param name="configurations">The role configurations</param> public void AutoRegisterRoles ( params ReportRoleConfiguration[] configurations ) { Validate.IsNotNull(configurations); var changesMade = false; foreach (var configuration in configurations) { var exists = _roleRepository.RoleExists ( configuration.Name ); if (exists) { var role = _roleRepository.GetRole ( configuration.Name ); role.Configure(configuration); _roleRepository.UpdateRole(role); changesMade = true; } else { var role = new ReportRole ( configuration ); _roleRepository.AddRole(role); changesMade = true; } } if (changesMade) { _unitOfWork.SaveChanges(); } }