diff --git a/PostmanTestRequest/StudentOperations.postman_collection.json b/PostmanTestRequest/StudentOperations.postman_collection.json index a3097d1..6410e88 100644 --- a/PostmanTestRequest/StudentOperations.postman_collection.json +++ b/PostmanTestRequest/StudentOperations.postman_collection.json @@ -33,7 +33,7 @@ "bearer": [ { "key": "token", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI", "type": "string" } ] @@ -52,7 +52,7 @@ } ], "url": { - "raw": "http://localhost:8080/management/internship?OrderByField=InternshipState&SortOrder=Desc", + "raw": "http://localhost:8080/management/internship?OrderByField=InternshipState&SortOrder=Asc", "protocol": "http", "host": [ "localhost" @@ -69,7 +69,7 @@ }, { "key": "SortOrder", - "value": "Desc" + "value": "Asc" } ] } @@ -84,7 +84,7 @@ "bearer": [ { "key": "token", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI", "type": "string" } ] @@ -126,7 +126,7 @@ "bearer": [ { "key": "token", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI", "type": "string" } ] @@ -144,6 +144,10 @@ "value": "application/json" } ], + "body": { + "mode": "raw", + "raw": "\"\"" + }, "url": { "raw": "http://localhost:8080/management/internship/accept/1", "protocol": "http", @@ -169,7 +173,7 @@ "bearer": [ { "key": "token", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjI1MTk5LCJleHAiOjE2MTAzMTE1OTksImlhdCI6MTYxMDIyNTE5OX0.KjIUgRh0RwqlA8K3U49ZZKKw8VHxhoW4fHIwUP4lyOc", + "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6ImZpcnN0bmFtZSIsImZhbWlseV9uYW1lIjoibGFzdG5hbWUiLCJQZXJzb25OdW1iZXIiOiIxIiwibmJmIjoxNjEwMjY2MzcxLCJleHAiOjE2MTAzNTI3NzEsImlhdCI6MTYxMDI2NjM3MX0.PDrMjCHJlpN2FApL6rC-UAoH1ZWAnUImwWfTDhvB5wI", "type": "string" } ] @@ -187,6 +191,10 @@ "value": "application/json" } ], + "body": { + "mode": "raw", + "raw": "\"Co żeś odrąbał andzeju\"" + }, "url": { "raw": "http://localhost:8080/management/internship/reject/1", "protocol": "http", @@ -855,6 +863,5 @@ }, "response": [] } - ], - "protocolProfileBehavior": {} + ] } \ No newline at end of file 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/20210110173006_Init.Designer.cs b/src/InternshipSystem.Repository/Migrations/20210110173104_Init.Designer.cs similarity index 99% rename from src/InternshipSystem.Repository/Migrations/20210110173006_Init.Designer.cs rename to src/InternshipSystem.Repository/Migrations/20210110173104_Init.Designer.cs index ed77292..841b958 100644 --- a/src/InternshipSystem.Repository/Migrations/20210110173006_Init.Designer.cs +++ b/src/InternshipSystem.Repository/Migrations/20210110173104_Init.Designer.cs @@ -10,7 +10,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace InternshipSystem.Repository.Migrations { [DbContext(typeof(InternshipDbContext))] - [Migration("20210110173006_Init")] + [Migration("20210110173104_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/20210110173006_Init.cs b/src/InternshipSystem.Repository/Migrations/20210110173104_Init.cs similarity index 99% rename from src/InternshipSystem.Repository/Migrations/20210110173006_Init.cs rename to src/InternshipSystem.Repository/Migrations/20210110173104_Init.cs index b55c366..eb44433 100644 --- a/src/InternshipSystem.Repository/Migrations/20210110173006_Init.cs +++ b/src/InternshipSystem.Repository/Migrations/20210110173104_Init.cs @@ -198,7 +198,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 ad39bf2..92eebdb 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");