61 lines
1.8 KiB
C#

using System.ComponentModel;
namespace SessionResults_Kudyaeva.Entities;
public class Statement
{
public int Id { get; private set; }
[Browsable(false)]
public int TeacherId { get; private set; }
[Browsable(false)]
public int DisciplineId { get; private set; }
[Browsable(false)]
public string TeacherSurname { get; private set; } = string.Empty;
[Browsable(false)]
public string TeacherName { get; private set; } = string.Empty;
[Browsable(false)]
public string TeacherMiddleName { get; private set; } = string.Empty;
[DisplayName("Преподаватель")]
public string TeacherDisplayName => $"{TeacherSurname} {TeacherName[0]}. {TeacherMiddleName[0]}.";
[DisplayName("Предмет")]
public string DisciplineName { get; private set; } = string.Empty;
[DisplayName("Дата")]
public DateTime Date { get; private set; }
[DisplayName("Оценки")]
public string Fuel => StatementStudents != null ?
string.Join(", ", StatementStudents.Select(x => $"{x.StudentDisplayName} {(int)x.Mark}")) :
string.Empty;
[Browsable(false)]
public IEnumerable<StatementStudent> StatementStudents { get; private set; } = [];
public static Statement CreateOperation(int id, int teacherId, int disciplineId, DateTime date, IEnumerable<StatementStudent> statementStudents)
{
return new Statement
{
Id = id,
TeacherId = teacherId,
DisciplineId = disciplineId,
Date = date,
StatementStudents = statementStudents
};
}
public void SetStatementStudents(IEnumerable<StatementStudent> statementStudents)
{
if (statementStudents != null && statementStudents.Any())
{
StatementStudents = statementStudents;
}
}
}