From 68bb545353ee26cffa2274306754cbfcebd4e204 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 18 Nov 2022 14:44:59 -0500 Subject: [PATCH] PS-1806 fix boolean logic with UserCollectionDetailsQuery query (#2424) * fix logic in user collection details query * remove pragma * remove pragma --- .../Queries/UserCollectionDetailsQuery.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Infrastructure.EntityFramework/Repositories/Queries/UserCollectionDetailsQuery.cs b/src/Infrastructure.EntityFramework/Repositories/Queries/UserCollectionDetailsQuery.cs index 00083472d8..fa84b3c651 100644 --- a/src/Infrastructure.EntityFramework/Repositories/Queries/UserCollectionDetailsQuery.cs +++ b/src/Infrastructure.EntityFramework/Repositories/Queries/UserCollectionDetailsQuery.cs @@ -45,8 +45,7 @@ public class UserCollectionDetailsQuery : IQuery o.Enabled && (ou.AccessAll || cu.CollectionId != null || g.AccessAll || cg.CollectionId != null) select new { c, ou, o, cu, gu, g, cg }; -#pragma warning disable IDE0075 - // I want to leave the ReadOnly and HidePasswords the way they are because it helps show the exact logic we are trying to replicate + return query.Select(x => new CollectionDetails { Id = x.c.Id, @@ -55,11 +54,10 @@ public class UserCollectionDetailsQuery : IQuery ExternalId = x.c.ExternalId, CreationDate = x.c.CreationDate, RevisionDate = x.c.RevisionDate, - ReadOnly = x.ou.AccessAll || x.g.AccessAll || ((x.cu != null ? x.cu.ReadOnly : (bool?)null) ?? (x.cg != null ? x.cg.ReadOnly : (bool?)null) ?? false) ? false : true, - HidePasswords = x.ou.AccessAll || x.g.AccessAll || ((x.cu != null ? x.cu.HidePasswords : (bool?)null) ?? (x.cg != null ? x.cg.HidePasswords : (bool?)null) ?? false) ? false : true, + ReadOnly = x.ou.AccessAll || x.g.AccessAll || + !((bool?)x.cu.ReadOnly ?? (bool?)x.cg.ReadOnly ?? false) ? false : true, + HidePasswords = x.ou.AccessAll || x.g.AccessAll || + !((bool?)x.cu.HidePasswords ?? (bool?)x.cg.HidePasswords ?? false) ? false : true, }); -#pragma warning restore IDE0075 } - - }