File tree Expand file tree Collapse file tree
WebUntisAPI.Client/Models Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33using System . Collections . Generic ;
44using System . Diagnostics ;
55using System . Linq ;
6+ using System . Net . Http ;
67using System . Text ;
8+ using System . Threading ;
79using System . Threading . Tasks ;
810using WebUntisAPI . Client . Converter ;
11+ using WebUntisAPI . Client . Exceptions ;
912
1013namespace WebUntisAPI . Client . Models
1114{
@@ -41,5 +44,21 @@ public struct Class
4144 /// An array of all teachers of the class
4245 /// </summary>
4346 public int [ ] Teachers { get ; set ; }
47+
48+ /// <summary>
49+ /// Get all taechers of this class
50+ /// </summary>
51+ /// <param name="client">The client for the request (This should be the same client with that you requested the class)</param>
52+ /// <param name="id">Identifier for the request</param>
53+ /// <param name="ct">Cancellation token</param>
54+ /// <returns>The teachers of the class</returns>
55+ /// <exception cref="UnauthorizedAccessException">Thrown when the client aren't not logged in</exception>
56+ /// <exception cref="HttpRequestException">Thrown when there was an error while the http request</exception>
57+ /// <exception cref="WebUntisException">Thrown when the WebUntis API returned an error</exception>
58+ public async Task < Teacher [ ] > GetTeachersAsync ( WebUntisClient client , string id = "getClassTeachers" , CancellationToken ct = default )
59+ {
60+ int [ ] classTeachers = Teachers ;
61+ return ( await client . GetAllTeachersAsync ( id , ct ) ) . Where ( t => classTeachers . Contains ( t . Id ) ) . ToArray ( ) ;
62+ }
4463 }
4564}
You can’t perform that action at this time.
0 commit comments