diff --git a/src/InternshipSystem.Api/Controllers/InternshipManagementController.cs b/src/InternshipSystem.Api/Controllers/InternshipManagementController.cs index 3ce0adb..2b7309a 100644 --- a/src/InternshipSystem.Api/Controllers/InternshipManagementController.cs +++ b/src/InternshipSystem.Api/Controllers/InternshipManagementController.cs @@ -35,7 +35,9 @@ namespace InternshipSystem.Api.Controllers Context.Internships .Include(i => i.Edition) .Include(i => i.InternshipRegistration) + .Include(i => i.InternshipRegistration.Type) .Include(i => i.Student) + .Include(i => i.Documentation) .Where(i => !searchQuery.EditionId.HasValue || i.Edition.Id.Equals(searchQuery.EditionId)) .Where(i => !searchQuery.InternshipState.HasValue || i.InternshipRegistration.State.Equals(searchQuery.InternshipState)) .Where(i => !searchQuery.StudentAlbumNumber.HasValue || i.Student.AlbumNumber.Equals(searchQuery.StudentAlbumNumber)) @@ -76,7 +78,7 @@ namespace InternshipSystem.Api.Controllers .Include(i => i.InternshipRegistration.BranchAddress) .Include(i => i.InternshipRegistration.Type) .Include(i => i.InternshipRegistration.Subjects) - .ThenInclude(subject => subject.Subject) + .ThenInclude(subject => subject.Subject) .Include(i => i.InternshipRegistration.Mentor) .Include(i => i.Report) .Include(i => i.Documentation) @@ -97,7 +99,7 @@ namespace InternshipSystem.Api.Controllers [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize(Policy = Policies.IsOverseer)] - public async Task AcceptInternship(long internshipId, CancellationToken token) + public async Task AcceptInternship(long internshipId, [FromBody] string comment, CancellationToken token) { var internship = await Context.Internships .Include(i => i.InternshipRegistration) @@ -109,7 +111,8 @@ namespace InternshipSystem.Api.Controllers } internship.InternshipRegistration.State = DocumentState.Accepted; - + internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment; + await Context.SaveChangesAsync(token); return Ok(); @@ -120,7 +123,7 @@ namespace InternshipSystem.Api.Controllers [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize(Policy = Policies.IsOverseer)] - public async Task RejectInternship(long internshipId, CancellationToken token) + public async Task RejectInternship(long internshipId, [FromBody] string comment, CancellationToken token) { var internship = await Context.Internships .Include(i => i.InternshipRegistration) @@ -132,6 +135,7 @@ namespace InternshipSystem.Api.Controllers } internship.InternshipRegistration.State = DocumentState.Rejected; + internship.InternshipRegistration.ChangeStateComment = string.IsNullOrEmpty(comment) ? null : comment; await Context.SaveChangesAsync(token); diff --git a/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs b/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs index 0c999a9..cde137e 100644 --- a/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs +++ b/src/InternshipSystem.Core/Entity/Internship/InternshipRegistration.cs @@ -19,6 +19,7 @@ namespace InternshipSystem.Core.Entity.Internship public InternshipType Type { get; set; } public int DeclaredHours { get; set; } public DocumentState State { get; set; } + public string ChangeStateComment { get; set; } public static InternshipRegistration Create() { diff --git a/src/InternshipSystem.Repository/Migrations/20210109193303_init.Designer.cs b/src/InternshipSystem.Repository/Migrations/20210110082601_init.Designer.cs similarity index 99% rename from src/InternshipSystem.Repository/Migrations/20210109193303_init.Designer.cs rename to src/InternshipSystem.Repository/Migrations/20210110082601_init.Designer.cs index 049b8d1..c8c7552 100644 --- a/src/InternshipSystem.Repository/Migrations/20210109193303_init.Designer.cs +++ b/src/InternshipSystem.Repository/Migrations/20210110082601_init.Designer.cs @@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace InternshipSystem.Repository.Migrations { [DbContext(typeof(InternshipDbContext))] - [Migration("20210109193303_init")] + [Migration("20210110082601_init")] partial class init { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -249,6 +249,10 @@ namespace InternshipSystem.Repository.Migrations .HasColumnName("branch_address_id") .HasColumnType("bigint"); + b.Property("ChangeStateComment") + .HasColumnName("change_state_comment") + .HasColumnType("text"); + b.Property("CompanyId") .HasColumnName("company_id") .HasColumnType("bigint"); diff --git a/src/InternshipSystem.Repository/Migrations/20210109193303_init.cs b/src/InternshipSystem.Repository/Migrations/20210110082601_init.cs similarity index 99% rename from src/InternshipSystem.Repository/Migrations/20210109193303_init.cs rename to src/InternshipSystem.Repository/Migrations/20210110082601_init.cs index 406b485..4d85f78 100644 --- a/src/InternshipSystem.Repository/Migrations/20210109193303_init.cs +++ b/src/InternshipSystem.Repository/Migrations/20210110082601_init.cs @@ -180,7 +180,8 @@ namespace InternshipSystem.Repository.Migrations phone_number = table.Column(nullable: true), type_id = table.Column(nullable: true), declared_hours = table.Column(nullable: false), - state = table.Column(nullable: false) + state = table.Column(nullable: false), + change_state_comment = table.Column(nullable: true) }, constraints: table => { diff --git a/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs b/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs index 032fcad..604909e 100644 --- a/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs +++ b/src/InternshipSystem.Repository/Migrations/InternshipDbContextModelSnapshot.cs @@ -247,6 +247,10 @@ namespace InternshipSystem.Repository.Migrations .HasColumnName("branch_address_id") .HasColumnType("bigint"); + b.Property("ChangeStateComment") + .HasColumnName("change_state_comment") + .HasColumnType("text"); + b.Property("CompanyId") .HasColumnName("company_id") .HasColumnType("bigint");