59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using InternshipSystem.Core.Entity.Internship;
|
|
using InternshipSystem.Core.UglyOrmArtifacts;
|
|
|
|
namespace InternshipSystem.Core
|
|
{
|
|
public class Edition
|
|
{
|
|
public Guid Id { get; set; }
|
|
public DateTime EditionStart { get; set; }
|
|
public DateTime EditionFinish { get; set; }
|
|
public DateTime ReportingStart { get; set; }
|
|
public Course Course { get; set; }
|
|
public List<Internship> Internships { get; set; }
|
|
public List<EditionSubject> AvailableSubjects { get; set; }
|
|
public List<EditionInternshipType> AvailableInternshipTypes { get; set; }
|
|
|
|
public bool IsOpen => EditionFinish < DateTime.Today;
|
|
|
|
public Edition CreateEdition(DateTime start, DateTime end, DateTime reportingStart)
|
|
{
|
|
return new Edition
|
|
{
|
|
EditionStart = start,
|
|
EditionFinish = end,
|
|
ReportingStart = reportingStart
|
|
};
|
|
}
|
|
|
|
public void RegisterInternship(Student student)
|
|
{
|
|
if (Internships.Any(i => i.Student.Id == student.Id))
|
|
{
|
|
throw new ArgumentException("error.registration.already_registered");
|
|
}
|
|
|
|
var internship = Internship.CreateStudentsInternship(student);
|
|
|
|
Internships.Add(internship);
|
|
}
|
|
|
|
public bool IsDateDuringEdition(DateTime start, DateTime end)
|
|
{
|
|
return start >= EditionStart && end <= EditionFinish;
|
|
}
|
|
|
|
public bool IsTypeAvailable(InternshipType internshipType)
|
|
{
|
|
return AvailableInternshipTypes.Any(e => e.InternshipType == internshipType);
|
|
}
|
|
|
|
public bool AreSubjectsAvailable(IEnumerable<long> internshipSubjects)
|
|
{
|
|
return internshipSubjects.All(s => AvailableSubjects.Any(su => su.InternshipSubjectId == s));
|
|
}
|
|
}
|
|
} |