| @@ -39,6 +39,7 @@ namespace Diligent.WebAPI.Business.Services | |||
| { | |||
| var applicant = await _context.Applicants | |||
| .Include(a => a.SelectionProcesses).ThenInclude(sp => sp.SelectionLevel) | |||
| .Include(a => a.SelectionProcesses).ThenInclude(sp => sp.Scheduler) | |||
| .FirstOrDefaultAsync(a => a.ApplicantId == id); | |||
| if (applicant is null) | |||
| @@ -9,7 +9,7 @@ namespace Diligent.WebAPI.Business.Services.Interfaces | |||
| Task DeleteAsync(int id); | |||
| Task<List<SelectionProcessResposneDto>> GetAllAsync(); | |||
| Task<SelectionProcessResposneDto> GetByIdAsync(int id); | |||
| Task<bool> FinishSelectionProcess(int id); | |||
| Task<bool> FinishSelectionProcess(SelectionProcessCreateDto model); | |||
| Task UpdateAsync(int id, SelectionProcessCreateDto model); | |||
| } | |||
| } | |||
| @@ -60,9 +60,9 @@ namespace Diligent.WebAPI.Business.Services | |||
| await _context.SaveChangesAsync(); | |||
| } | |||
| public async Task<bool> FinishSelectionProcess(int id) | |||
| public async Task<bool> FinishSelectionProcess(SelectionProcessCreateDto model) | |||
| { | |||
| var sp = await _context.SelectionProcesses.FindAsync(id); | |||
| var sp = await _context.SelectionProcesses.FindAsync(model.Id); | |||
| if (sp is null) | |||
| throw new EntityNotFoundException("Selection process not found"); | |||
| @@ -76,10 +76,11 @@ namespace Diligent.WebAPI.Business.Services | |||
| SelectionProcess newProcess = new SelectionProcess | |||
| { | |||
| Name = sp.Name, | |||
| Name = model.Name, | |||
| SelectionLevelId = nextLevel.Id, | |||
| Status = "Čeka na zakazivanje", | |||
| ApplicantId = sp.ApplicantId | |||
| ApplicantId = sp.ApplicantId, | |||
| SchedulerId = model.SchedulerId | |||
| }; | |||
| _context.SelectionProcesses.Add(newProcess); | |||
| @@ -2,11 +2,12 @@ | |||
| { | |||
| public class SelectionProcessCreateDto | |||
| { | |||
| public string Name { get; set; } | |||
| public string Status { get; set; } | |||
| public int Id { get; set; } | |||
| public string? Name { get; set; } | |||
| public string? Status { get; set; } | |||
| public DateTime? Date { get; set; } | |||
| public string? Link { get; set; } | |||
| public int? SchedulerId { get; set; } | |||
| public int SchedulerId { get; set; } | |||
| public int SelectionLevelId { get; set; } | |||
| public int ApplicantId { get; set; } | |||
| } | |||
| @@ -8,7 +8,7 @@ namespace Diligent.WebAPI.Contracts.DTOs.SelectionProcess | |||
| public string Status { get; set; } | |||
| public DateTime? Date { get; set; } | |||
| public string? Link { get; set; } | |||
| public UserResponseDTO User { get; set; } | |||
| public UserResponseDTO Scheduler { get; set; } | |||
| public SelectionLevelResposneDto SelectionLevel { get; set; } | |||
| } | |||
| } | |||
| @@ -19,16 +19,16 @@ namespace Diligent.WebAPI.Host.Controllers.V1 | |||
| public async Task<IActionResult> GetAll() => | |||
| Ok(await _selectionProcessesService.GetAllAsync()); | |||
| [HttpGet("{id}")] | |||
| public async Task<IActionResult> FinishSelectionProcess([FromRoute] int id) => | |||
| Ok(await _selectionProcessesService.FinishSelectionProcess(id)); | |||
| [HttpPost] | |||
| public async Task<IActionResult> Create([FromBody] SelectionProcessCreateDto request) | |||
| { | |||
| await _selectionProcessesService.CreateAsync(request); | |||
| return StatusCode((int)HttpStatusCode.Created); | |||
| } | |||
| public async Task<IActionResult> FinishSelectionProcess([FromBody] SelectionProcessCreateDto model) => | |||
| Ok(await _selectionProcessesService.FinishSelectionProcess(model)); | |||
| //[HttpPost] | |||
| //public async Task<IActionResult> Create([FromBody] SelectionProcessCreateDto request) | |||
| //{ | |||
| // await _selectionProcessesService.CreateAsync(request); | |||
| // return StatusCode((int)HttpStatusCode.Created); | |||
| //} | |||
| [HttpPut("{id}")] | |||
| public async Task<IActionResult> Update([FromBody] SelectionProcessCreateDto request, [FromRoute] int id) | |||