From 8001d9d911f54aecc2115fd14ff9165cb55ea654 Mon Sep 17 00:00:00 2001
From: MaxchilKH <m.w.bohdanowicz@gmail.com>
Date: Sun, 4 Oct 2020 12:48:07 +0200
Subject: [PATCH 1/2] fix

---
 .../Controllers/EditionController.cs          | 27 +++++++++++++++++++
 .../Controllers/InternshipTypesController.cs  |  8 +++---
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/InternshipSystem.Api/Controllers/EditionController.cs b/src/InternshipSystem.Api/Controllers/EditionController.cs
index 0708c9b..40834d4 100644
--- a/src/InternshipSystem.Api/Controllers/EditionController.cs
+++ b/src/InternshipSystem.Api/Controllers/EditionController.cs
@@ -56,6 +56,33 @@ namespace InternshipSystem.Api.Controllers
             return Ok(editions);
         }
         
+        /// <summary>
+        /// Get accessible editions
+        /// </summary>
+        /// <response code="200">Editions accessible by the current user</response>
+        /// <response code="401">This action is only available for authorized student</response>
+        /// <response code="404"/>
+        /// <returns></returns>
+        [HttpGet("{id}")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [ProducesResponseType(StatusCodes.Status401Unauthorized)]
+        [ProducesResponseType(StatusCodes.Status404NotFound)]
+        public async Task<ActionResult<EditionResult>> GetEditionInfo(Guid id, CancellationToken token)
+        {
+            var edition = 
+                await Context.Editions
+                    .Where(e => e.Id == id)
+                    .ProjectTo<EditionResult?>(Mapper.ConfigurationProvider)
+                    .FirstOrDefaultAsync(token);
+            
+            if (edition == null) 
+            {
+                return NotFound();
+            }
+            
+            return Ok(edition);
+        }
+        
         /// <summary>
         /// Get current edition's configuration
         /// </summary>
diff --git a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs
index e14df07..9fa8ccb 100644
--- a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs
+++ b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs
@@ -28,7 +28,7 @@ namespace InternshipSystem.Api.Controllers
         /// Get internship types available for current edition
         /// </summary>
         /// <returns>List of internship types for current edition</returns>
-        [HttpGet]
+        [HttpGet("current")]
         [ProducesResponseType(StatusCodes.Status200OK)]
         [ProducesResponseType(StatusCodes.Status401Unauthorized)]
         [ProducesResponseType(StatusCodes.Status404NotFound)]
@@ -88,7 +88,7 @@ namespace InternshipSystem.Api.Controllers
         }
 
         /// <summary>
-        /// Add or update internship type
+        /// Add or update internship type, only available for coordinator
         /// </summary>
         /// <response code="200">Internship type updated successfully</response>
         /// <response code="400">Invalid internship type form</response>
@@ -100,7 +100,7 @@ namespace InternshipSystem.Api.Controllers
         [ProducesResponseType(StatusCodes.Status401Unauthorized)]
         [ProducesResponseType(StatusCodes.Status404NotFound)]
         [Authorize]
-        public async Task<ActionResult> UpdateInternshipType([FromBody] InternshipTypeFrom internshipTypeFrom, CancellationToken cancellationToken)
+        public async Task<ActionResult> UpsertInternshipType([FromBody] InternshipTypeFrom internshipTypeFrom, CancellationToken cancellationToken)
         {
             var validator = new InternshipTypeFrom.Validator();
             var validationResult = await validator.ValidateAsync(internshipTypeFrom, cancellationToken);
@@ -138,7 +138,7 @@ namespace InternshipSystem.Api.Controllers
             }
 
             await Context.SaveChangesAsync(cancellationToken);
-            return Ok($"Internship type updated successfully");
+            return Ok();
         }
 
         /// <summary>
-- 
2.45.2


From 47dfde30e9c07cb25222caffd09e35746086cc35 Mon Sep 17 00:00:00 2001
From: MaxchilKH <m.w.bohdanowicz@gmail.com>
Date: Sun, 4 Oct 2020 13:30:12 +0200
Subject: [PATCH 2/2] add

---
 .../Controllers/InternshipTypesController.cs                     | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs
index 9fa8ccb..41b218d 100644
--- a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs
+++ b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs
@@ -38,6 +38,7 @@ namespace InternshipSystem.Api.Controllers
             var edition = 
                 await Context.Editions
                     .Include(e => e.AvailableInternshipTypes)
+                        .ThenInclude(e => e.InternshipType)
                     .Where(e => e.Id.Equals(user.EditionId))
                     .FirstOrDefaultAsync(cancellationToken: cancellationToken);
 
-- 
2.45.2