using EnertechWebAPI.Interfaces; using EnertechWebAPI.Responses; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace EnertechWebAPI.Controllers { [Authorize] [Route("api/[controller]")] [ApiController] public class EducationController : BaseApiController { private readonly IEducationService educationService; public EducationController(IEducationService educationService) { this.educationService = educationService; } [HttpGet] public async Task Get() { var getEducationResponse = await educationService.GetEducation(UserID); if (!getEducationResponse.Success) { return UnprocessableEntity(getEducationResponse); } var educationResponse = getEducationResponse.UserEducations.ConvertAll(o => new UserEducationResponse { EducationId = o.EducationId, EducationCredits = o.EducationCredits, EducationName = o.EducationName, Completed = o.Completed }); return Ok(educationResponse); } [HttpPut("{educaionId}")] public async Task Put(int educaionId) { var putEducationResponse = await educationService.PutEducation(UserID, educaionId); if (!putEducationResponse.Success) { return UnprocessableEntity(putEducationResponse); } return Ok(putEducationResponse); } } }