69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
namespace MeetTheTeacher.Model;
|
|
|
|
/// <summary>
|
|
/// Represents a teacher at a vocational college
|
|
/// </summary>
|
|
/// <inheritdoc cref="ICsvRepresentable" />
|
|
public class Teacher : ICsvRepresentable
|
|
{
|
|
/// <summary>
|
|
/// Creates a new instance of <see cref="Teacher" />.
|
|
/// The name is the only required property.
|
|
/// </summary>
|
|
/// <param name="name">Name of the teacher</param>
|
|
public Teacher(string name)
|
|
{
|
|
Name = name;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the name of the teacher
|
|
/// </summary>
|
|
public string Name { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the time frame in which the teacher is available for consulting
|
|
/// </summary>
|
|
public TimeFrame? ConsultingHour { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the school unit in which the teacher is available for consulting
|
|
/// </summary>
|
|
public SchoolUnit? ConsultingHourUnit { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the day of the week the teacher is available for consulting
|
|
/// </summary>
|
|
public DayOfWeek? ConsultingHourWeekDay { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the room in which the teacher is available for consulting
|
|
/// </summary>
|
|
public string? Room { get; init; }
|
|
|
|
private string? ConsultingHourTime
|
|
{
|
|
get
|
|
{
|
|
if (ConsultingHour == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return ConsultingHourUnit == null ? ConsultingHour.ToString() : $"{ConsultingHour} ({ConsultingHourUnit})";
|
|
}
|
|
}
|
|
|
|
public virtual CsvData ToCsvData()
|
|
{
|
|
List<string> headerNames = ["Name", "Day", "ConsultingHour", "Room"];
|
|
List<string> dataLine = [
|
|
Name,
|
|
ConsultingHourWeekDay?.ToString() ?? string.Empty,
|
|
ConsultingHourTime ?? string.Empty,
|
|
Room ?? string.Empty
|
|
];
|
|
var data = new CsvData(headerNames, dataLine);
|
|
return data;
|
|
}
|
|
}
|