예제 #1
0
 public static GroupPatch WithAllPrivacy(this GroupPatch member, PrivacyLevel level)
 {
     foreach (var subject in Enum.GetValues(typeof(GroupPrivacySubject)))
     {
         member.WithPrivacy((GroupPrivacySubject)subject, level);
     }
     return(member);
 }
예제 #2
0
 public Task <PKGroup> UpdateGroup(IPKConnection conn, GroupId id, GroupPatch patch)
 {
     _logger.Information("Updated {GroupId}: {@GroupPatch}", id, patch);
     var(query, pms) = patch.Apply(UpdateQueryBuilder.Update("groups", "id = @id"))
                       .WithConstant("id", id)
                       .Build("returning *");
     return(conn.QueryFirstAsync <PKGroup>(query, pms));
 }
예제 #3
0
        public static GroupPatch WithPrivacy(this GroupPatch group, GroupPrivacySubject subject, PrivacyLevel level)
        {
            // what do you mean switch expressions can't be statements >.>
            _ = subject switch
            {
                GroupPrivacySubject.Description => group.DescriptionPrivacy = level,
                GroupPrivacySubject.Icon => group.IconPrivacy      = level,
                GroupPrivacySubject.List => group.ListPrivacy      = level,
                GroupPrivacySubject.Visibility => group.Visibility = level,
                _ => throw new ArgumentOutOfRangeException($"Unknown privacy subject {subject}")
            };

            return(group);
        }
예제 #4
0
 public static Task <PKGroup> UpdateGroup(this IPKConnection conn, GroupId id, GroupPatch patch)
 {
     var(query, pms) = patch.Apply(UpdateQueryBuilder.Update("groups", "id = @id"))
                       .WithConstant("id", id)
                       .Build("returning *");
     return(conn.QueryFirstAsync <PKGroup>(query, pms));
 }