From 655b084c96ee25a13225f6a2db84f8f062c5febe Mon Sep 17 00:00:00 2001 From: mborzyszkowski Date: Sat, 5 Sep 2020 20:50:22 +0200 Subject: [PATCH] Resolve InternshipType List in Edition problem --- .../Controllers/CompaniesController.cs | 2 +- src/InternshipSystem.Core/Entity/Edition.cs | 5 +++-- .../Entity/Internship/InternshipType.cs | 16 ++++++++-------- .../UglyOrmArtifacts/EditionInternshipType.cs | 11 +++++++++++ .../DatabaseFiller.cs | 10 +++++----- 5 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 src/InternshipSystem.Core/UglyOrmArtifacts/EditionInternshipType.cs diff --git a/src/InternshipSystem.Api/Controllers/CompaniesController.cs b/src/InternshipSystem.Api/Controllers/CompaniesController.cs index 430e81d..b23aaef 100644 --- a/src/InternshipSystem.Api/Controllers/CompaniesController.cs +++ b/src/InternshipSystem.Api/Controllers/CompaniesController.cs @@ -38,7 +38,7 @@ namespace InternshipSystem.Api.Controllers .ToListAsync(cancellationToken); /// - /// Get companies matching provided paginated query + /// Get company branches matching provided paginated query /// /// Paginated query description /// diff --git a/src/InternshipSystem.Core/Entity/Edition.cs b/src/InternshipSystem.Core/Entity/Edition.cs index 53f64ad..d6ee476 100644 --- a/src/InternshipSystem.Core/Entity/Edition.cs +++ b/src/InternshipSystem.Core/Entity/Edition.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using InternshipSystem.Core.Entity.Internship; using InternshipSystem.Core.UglyOrmArtifacts; @@ -14,7 +15,7 @@ namespace InternshipSystem.Core public Course Course { get; set; } public List Internships { get; set; } public List AvailableSubjects { get; set; } - public List AvailableInternshipTypes { get; set; } + public List AvailableInternshipTypes { get; set; } public bool IsOpen => EditionFinish < DateTime.Today; @@ -30,7 +31,7 @@ namespace InternshipSystem.Core public bool IsInternshipTypeAllowed(InternshipType registrationQueryType) { - return AvailableInternshipTypes.Contains(registrationQueryType); + return AvailableInternshipTypes.Select(it => it.InternshipType).Contains(registrationQueryType); } public void RegisterInternship(Student student) diff --git a/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs index 0f554e0..e810e05 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipType.cs @@ -2,13 +2,13 @@ { public enum InternshipType { - FreeInternship, - GraduateInternship, - FreeApprenticeship, - PaidApprenticeship, - ForeignInternship, - UOP, - UD, - UZ + FreeInternship = 0, + GraduateInternship = 1, + FreeApprenticeship = 2, + PaidApprenticeship = 3, + ForeignInternship = 4, + UOP = 5, + UD = 6, + UZ = 7, } } \ No newline at end of file diff --git a/src/InternshipSystem.Core/UglyOrmArtifacts/EditionInternshipType.cs b/src/InternshipSystem.Core/UglyOrmArtifacts/EditionInternshipType.cs new file mode 100644 index 0000000..f8c03c2 --- /dev/null +++ b/src/InternshipSystem.Core/UglyOrmArtifacts/EditionInternshipType.cs @@ -0,0 +1,11 @@ +using System; +using InternshipSystem.Core.Entity.Internship; + +namespace InternshipSystem.Core.UglyOrmArtifacts +{ + public class EditionInternshipType + { + public long Id { get; set; } + public InternshipType InternshipType { get; set; } + } +} \ No newline at end of file diff --git a/src/InternshipSystem.Repository/DatabaseFiller.cs b/src/InternshipSystem.Repository/DatabaseFiller.cs index 1b898d1..c3f135a 100644 --- a/src/InternshipSystem.Repository/DatabaseFiller.cs +++ b/src/InternshipSystem.Repository/DatabaseFiller.cs @@ -139,12 +139,12 @@ namespace InternshipSystem.Repository { Name = "Informatyka", }, - AvailableInternshipTypes = new List + AvailableInternshipTypes = new List { - InternshipType.UOP, - InternshipType.UZ, - InternshipType.UD, - InternshipType.FreeInternship + new EditionInternshipType() { InternshipType = InternshipType.UOP }, + new EditionInternshipType() { InternshipType = InternshipType.UZ }, + new EditionInternshipType() { InternshipType = InternshipType.UD }, + new EditionInternshipType() { InternshipType = InternshipType.FreeInternship }, }, Internships = new List(), }