private RoleEGMSPermissionRM CreateRoleEGMSPermission(Commands.V1.RoleEGMSPermission.Create cmd) { RoleEGMSPermission roleEGMSPermission = RoleEGMSPermission.Create(_roleEGMSPermissions++, cmd.RoleId, cmd.EGMSPermissionId); if (_repository.RoleEGMSPermissionExists(cmd.RoleId, cmd.EGMSPermissionId)) { throw new InvalidOperationException($"RoleEGMSPermission already exists for Role {cmd.RoleId} and EGMSPermission {cmd.EGMSPermissionId}"); } _repository.AddRoleEGMSPermission(roleEGMSPermission); return(Conversions.GetRoleEGMSPermissionRM(roleEGMSPermission)); }