From 0ef4eeb0ac80bb02214642210885043843ccee23 Mon Sep 17 00:00:00 2001
From: mborzyszkowski <maciej.borzyszkowski@gmail.com>
Date: Sun, 10 Jan 2021 09:39:25 +0100
Subject: [PATCH 1/2] InternshipType and Documents added to list.
 ChangeStateComment field for accept and reject

---
 .../Controllers/InternshipManagementController.cs    | 12 ++++++++----
 .../Entity/Internship/InternshipRegistration.cs      |  1 +
 ...t.Designer.cs => 20210110082601_init.Designer.cs} |  6 +++++-
 ...20210109193303_init.cs => 20210110082601_init.cs} |  3 ++-
 .../Migrations/InternshipDbContextModelSnapshot.cs   |  4 ++++
 5 files changed, 20 insertions(+), 6 deletions(-)
 rename src/InternshipSystem.Repository/Migrations/{20210109193303_init.Designer.cs => 20210110082601_init.Designer.cs} (99%)
 rename src/InternshipSystem.Repository/Migrations/{20210109193303_init.cs => 20210110082601_init.cs} (99%)

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<ActionResult> AcceptInternship(long internshipId, CancellationToken token)
+        public async Task<ActionResult> 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<ActionResult> RejectInternship(long internshipId, CancellationToken token)
+        public async Task<ActionResult> 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<string>("ChangeStateComment")
+                        .HasColumnName("change_state_comment")
+                        .HasColumnType("text");
+
                     b.Property<long?>("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<string>(nullable: true),
                     type_id = table.Column<long>(nullable: true),
                     declared_hours = table.Column<int>(nullable: false),
-                    state = table.Column<int>(nullable: false)
+                    state = table.Column<int>(nullable: false),
+                    change_state_comment = table.Column<string>(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<string>("ChangeStateComment")
+                        .HasColumnName("change_state_comment")
+                        .HasColumnType("text");
+
                     b.Property<long?>("CompanyId")
                         .HasColumnName("company_id")
                         .HasColumnType("bigint");
-- 
2.45.2


From 520e986a555e8532ecd9fa3b80e54e1a7e36dade Mon Sep 17 00:00:00 2001
From: mborzyszkowski <maciej.borzyszkowski@gmail.com>
Date: Sun, 10 Jan 2021 09:40:30 +0100
Subject: [PATCH 2/2] PostmanTestRequest update

---
 .../StudentOperations.postman_collection.json | 23 ++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)

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
-- 
2.45.2