public static GroupPatch WithAllPrivacy(this GroupPatch member, PrivacyLevel level) { foreach (var subject in Enum.GetValues(typeof(GroupPrivacySubject))) { member.WithPrivacy((GroupPrivacySubject)subject, level); } return(member); }
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)); }
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); }
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)); }