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>