diff --git a/src/InternshipSystem.Api/Controllers/AccessController.cs b/src/InternshipSystem.Api/Controllers/AccessController.cs index 22e10bd..dafd2a7 100644 --- a/src/InternshipSystem.Api/Controllers/AccessController.cs +++ b/src/InternshipSystem.Api/Controllers/AccessController.cs @@ -1,12 +1,9 @@ using System; -using System.IO; using System.Linq; using System.Security.Claims; using System.Threading; using System.Threading.Tasks; -using FluentValidation; using InternshipSystem.Api.Options; -using InternshipSystem.Api.Queries; using InternshipSystem.Api.Security; using InternshipSystem.Core; using InternshipSystem.Repository; @@ -14,7 +11,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; -using Serilog; namespace InternshipSystem.Api.Controllers { @@ -40,8 +36,8 @@ namespace InternshipSystem.Api.Controllers } - [HttpGet("login")] - public async Task Authenticate(string code, CancellationToken cancellationToken) + [HttpPost("login")] + public async Task Authenticate([FromBody] string code, CancellationToken cancellationToken) { var token = await _loginClient.GetCasTokenAsync(code, cancellationToken); @@ -84,7 +80,7 @@ namespace InternshipSystem.Api.Controllers return Ok(_tokenService.generateToken(identity)); } - [HttpGet("loginEdition")] + [HttpPost("loginEdition")] [Authorize] public async Task LoginIntoEdition([FromBody] Guid editionId, [FromServices] User user, CancellationToken token) { diff --git a/src/InternshipSystem.Api/Controllers/CompaniesController.cs b/src/InternshipSystem.Api/Controllers/CompaniesController.cs index 9502fac..2d21d60 100644 --- a/src/InternshipSystem.Api/Controllers/CompaniesController.cs +++ b/src/InternshipSystem.Api/Controllers/CompaniesController.cs @@ -73,11 +73,13 @@ namespace InternshipSystem.Api.Controllers /// /// Successfully updated company /// Company form was malformed + /// This action is only available for authorized internship admin /// Company not found /// [HttpPut] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] public async Task UpdateCompany([FromBody] CompanyForm companyForm, CancellationToken cancellationToken) @@ -124,11 +126,13 @@ namespace InternshipSystem.Api.Controllers /// /// Successfully deleted company /// Company id is empty + /// This action is only available for authorized internship admin /// Company not found /// [HttpDelete("{companyId}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] public async Task DeleteCompany(long companyId, CancellationToken cancellationToken) @@ -154,12 +158,14 @@ namespace InternshipSystem.Api.Controllers /// /// /// Successfully updated company branch office - /// Branch office was malformed/response> + /// Branch office was malformed + /// This action is only available for authorized internship admin /// Company or branch office not found /// [HttpPut("branchOffice/{companyId}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] public async Task UpdateBranch([FromBody] BranchOfficeForm branchOfficeForm, long companyId, CancellationToken cancellationToken) @@ -222,11 +228,12 @@ namespace InternshipSystem.Api.Controllers /// /// Successfully deleted company branch office /// Branch office id is empty + /// This action is only available for authorized internship admin /// Company or branch office not found - /// [HttpDelete("branchOffice/{branchOfficeId}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] public async Task DeleteBranch(long branchOfficeId, CancellationToken cancellationToken) diff --git a/src/InternshipSystem.Api/Controllers/DocumentsController.cs b/src/InternshipSystem.Api/Controllers/DocumentsController.cs index b21af33..c88113b 100644 --- a/src/InternshipSystem.Api/Controllers/DocumentsController.cs +++ b/src/InternshipSystem.Api/Controllers/DocumentsController.cs @@ -24,7 +24,6 @@ namespace InternshipSystem.Api.Controllers /// Fill out required document, /// /// Documents Scan and description, and Id of filled document - /// /// If change was successfully registered /// If the provided query was malformed /// Id doesn't match any required document diff --git a/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs b/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs index 89a14b0..d2a98e9 100644 --- a/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs +++ b/src/InternshipSystem.Api/Controllers/InternshipRegistrationController.cs @@ -83,7 +83,12 @@ namespace InternshipSystem.Api.Controllers } } - + + /// + /// Get internship for current edition + /// + /// If current internship returned successfully + /// This action is only available for authorized student registered for current edition [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] diff --git a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs index de96fb6..f6f01ae 100644 --- a/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs +++ b/src/InternshipSystem.Api/Controllers/InternshipTypesController.cs @@ -25,10 +25,10 @@ namespace InternshipSystem.Api.Controllers } /// - /// Get static page + /// Get internship types available for current edition /// - /// List of internship types for edition - [HttpGet("forCurrentEdition")] + /// List of internship types for current edition + [HttpGet("current")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -49,6 +49,13 @@ namespace InternshipSystem.Api.Controllers return Ok(edition.AvailableInternshipTypes.Select(e => e.InternshipType)); } + /// + /// Get internship type by id + /// + /// Internship type + /// Internship type returned successfully + /// This action is only available for authorized internship admin + /// Internship type not found [HttpGet("{internshipTypeId}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] @@ -59,12 +66,17 @@ namespace InternshipSystem.Api.Controllers return await Context.InternshipTypes.FindAsync(internshipTypeId); } + /// + /// Get internship type list + /// + /// Internship type + /// Internship type list returned successfully + /// This action is only available for authorized internship admin [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] - public async Task>> SearchInternshipTypes([FromBody] InternshipTypeSearchQuery searchQuery, CancellationToken cancellationToken) + public async Task>> SearchInternshipTypes([FromQuery] InternshipTypeSearchQuery searchQuery, CancellationToken cancellationToken) { return await Context.InternshipTypes .Where(t => string.IsNullOrEmpty(searchQuery.Type) || t.Type.Contains(searchQuery.Type)) @@ -74,6 +86,13 @@ namespace InternshipSystem.Api.Controllers .ToListAsync(cancellationToken); } + /// + /// Add or update internship type + /// + /// Internship type updated successfully + /// Invalid internship type form + /// This action is only available for authorized internship admin + /// Internship type with selected id do not exist [HttpPut] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] @@ -119,9 +138,14 @@ namespace InternshipSystem.Api.Controllers return Ok($"Internship type updated successfully"); } + /// + /// Add or update internship type + /// + /// Internship type deleted successfully + /// This action is only available for authorized internship admin + /// Internship type with selected id do not exist [HttpDelete("{internshipTypeId}")] [ProducesResponseType(StatusCodes.Status200OK)] - [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] diff --git a/src/InternshipSystem.Api/Controllers/StaticPagesController.cs b/src/InternshipSystem.Api/Controllers/StaticPagesController.cs index 6eecde2..e9b602f 100644 --- a/src/InternshipSystem.Api/Controllers/StaticPagesController.cs +++ b/src/InternshipSystem.Api/Controllers/StaticPagesController.cs @@ -21,11 +21,12 @@ namespace InternshipSystem.Api.Controllers Context = context; } private InternshipDbContext Context { get; } - + /// /// Get all static pages /// /// List of static pages with titles and content + /// Static pages list returned successfully [HttpGet] [ProducesResponseType(StatusCodes.Status200OK)] public async Task>> GetStaticPages(CancellationToken cancellationToken) => @@ -37,6 +38,8 @@ namespace InternshipSystem.Api.Controllers /// /// Name of page /// Static page title and content + /// Static page returned successfully + /// Static page with given access name do not exist [HttpGet("{accessName}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status404NotFound)] @@ -55,6 +58,13 @@ namespace InternshipSystem.Api.Controllers return Ok(page); } + /// + /// Add or update static page + /// + /// Static page updated successfully + /// Static page form is not valid + /// This action is only available for authorized internship admin + /// Static page with given id do not exist [HttpPut] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] @@ -122,8 +132,13 @@ namespace InternshipSystem.Api.Controllers return Ok($"Static page updated successfully"); } - - + + /// + /// Delete static page + /// + /// Static page deleted successfully + /// This action is only available for authorized internship admin + /// Static page with given access name do not exist [HttpDelete("{accessName}")] [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] diff --git a/src/InternshipSystem.Api/Controllers/StudentsController.cs b/src/InternshipSystem.Api/Controllers/StudentsController.cs index a125f84..5897dbb 100644 --- a/src/InternshipSystem.Api/Controllers/StudentsController.cs +++ b/src/InternshipSystem.Api/Controllers/StudentsController.cs @@ -7,6 +7,7 @@ using InternshipSystem.Api.Security; using InternshipSystem.Core; using InternshipSystem.Repository; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -23,14 +24,29 @@ namespace InternshipSystem.Api.Controllers _context = context; } + /// + /// Get current student personal data + /// + /// Current student data + /// Current student data returned successfully + /// his action is only available for authorized student [HttpGet("current")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] [Authorize] public async Task> GetCurrentStudentData([FromServices] User user, CancellationToken cancellationToken) { return await _context.Students.FindAsync(user.PersonNumber); } - + + /// + /// Update current student personal data + /// + /// Current student data updated successfully + /// his action is only available for authorized student [HttpPut("current")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] [Authorize] public async Task UpdateCurrentStudentData([FromBody] CurrentStudentForm studentNewData, [FromServices] User user, CancellationToken cancellationToken) { @@ -47,15 +63,33 @@ namespace InternshipSystem.Api.Controllers return Ok($"Student updated successfully"); } - + + /// + /// Get student personal data + /// + /// Student personal data + /// Student data returned successfully + /// This action is only available for authorized internship admin + /// Student with given id do not exist [HttpGet("{studentPersonNumber}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] public async Task> GetStudentByPersonNumber(long studentPersonNumber, CancellationToken cancellationToken) => await _context.Students.FindAsync(studentPersonNumber); + /// + /// Search students personal data + /// + /// List of students personal data + /// List of student data + /// This action is only available for authorized internship admin [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] [Authorize] - public async Task>> GetStudents([FromBody] StudentSearchQuery searchQuery, CancellationToken cancellationToken) => + public async Task>> GetStudents([FromQuery] StudentSearchQuery searchQuery, CancellationToken cancellationToken) => await _context.Students .Where(s => !searchQuery.AlbumNumber.HasValue || s.AlbumNumber.Equals(searchQuery.AlbumNumber)) .Where(s => string.IsNullOrEmpty(searchQuery.FirstName) || s.FirstName.ToLower().Contains(searchQuery.FirstName.ToLower())) @@ -64,8 +98,18 @@ namespace InternshipSystem.Api.Controllers .Skip(searchQuery.Page * searchQuery.PerPage) .Take(searchQuery.PerPage) .ToListAsync(cancellationToken); - + + /// + /// Updates student personal data + /// + /// Student data updated successfully + /// This action is only available for authorized internship admin + /// Student with given id do not exist [HttpPut] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status400BadRequest)] + [ProducesResponseType(StatusCodes.Status401Unauthorized)] + [ProducesResponseType(StatusCodes.Status404NotFound)] [Authorize] public async Task UpdateStudentData([FromBody] StudentForm studentNewData, CancellationToken cancellationToken) { diff --git a/src/InternshipSystem.Api/InternshipSystem.Api.csproj b/src/InternshipSystem.Api/InternshipSystem.Api.csproj index 81e1ed3..00db90f 100644 --- a/src/InternshipSystem.Api/InternshipSystem.Api.csproj +++ b/src/InternshipSystem.Api/InternshipSystem.Api.csproj @@ -12,7 +12,7 @@ - +