ex-int-02-meet-the-teacher/MeetTheTeacher/Model/TeacherWithBusinessCard.cs
2025-04-24 23:34:37 +02:00

41 lines
1.3 KiB
C#

namespace MeetTheTeacher.Model;
/// <summary>
/// Represents a teacher with a business card which means they have an id for their picture available as well
/// </summary>
/// <inheritdoc cref="Teacher" />
public sealed class TeacherWithBusinessCard : Teacher
{
private const string BaseUrl = "https://www.htl-leonding.at/media/teacher-avatar";
/// <summary>
/// Creates a new instance of <see cref="TeacherWithBusinessCard" />.
/// In addition to the name, the id of the picture is required as well.
/// </summary>
/// <param name="name">Name of the teacher</param>
/// <param name="id">Id of the teacher's picture</param>
public TeacherWithBusinessCard(string name, int id) : base(name)
{
Id = id;
}
/// <summary>
/// Gets the picture id of the teacher
/// </summary>
public int Id { get; }
public override CsvData ToCsvData()
{
var data = base.ToCsvData();
(IReadOnlyList<string> headerNamesBase, IReadOnlyList<string> dataLineBase) = data;
var headerNames = (List<string>)headerNamesBase;
var dataLine = (List<string>)dataLineBase;
headerNames.Add("Image");
dataLine.Add($"{BaseUrl}/{Id}");
var csvData = new CsvData(headerNames, dataLine);
return csvData;
}
}