Просмотр исходного кода

implemented methods for interviewer selection

pull/121/head
meris.ahmatovic 3 лет назад
Родитель
Сommit
7bb188d890

+ 1
- 0
Diligent.WebAPI.Business/Services/Interfaces/ISelectionProcessService.cs Просмотреть файл

@@ -10,5 +10,6 @@ namespace Diligent.WebAPI.Business.Services.Interfaces
Task<bool> FinishSelectionProcess(SelectionProcessCreateDto model);
Task<List<SelectionLevelInfoDto>> GetCountByLevels(List<string> statuses);
Task UpdateSelectionProcessStatusAsync(int id, SelectionProcessUpdateStatusDto selectionProcessUpdateStatusDto);
Task StatusUpdate(StatusChangeDTO model);
}
}

+ 2
- 0
Diligent.WebAPI.Business/Services/SelectionLevelService.cs Просмотреть файл

@@ -20,6 +20,8 @@
var fromDb = await _context.SelectionLevels
.Include(sl => sl.SelectionProcesses)
.ThenInclude(sp => sp.Applicant)
.Include(sl => sl.SelectionProcesses)
.ThenInclude(sp => sp.Scheduler)
.ToListAsync();

_logger.LogInformation($"Received {fromDb.Count} levels from db.");

+ 29
- 2
Diligent.WebAPI.Business/Services/SelectionProcessService.cs Просмотреть файл

@@ -6,13 +6,15 @@ namespace Diligent.WebAPI.Business.Services
{
private readonly DatabaseContext _context;
private readonly IMapper _mapper;
private readonly UserManager<User> _userManager;
private readonly ILogger<SelectionProcessService> _logger;

public SelectionProcessService(DatabaseContext context, IMapper mapper, ILogger<SelectionProcessService> logger)
public SelectionProcessService(UserManager<User> userManager,DatabaseContext context, IMapper mapper, ILogger<SelectionProcessService> logger)
{
_context = context;
_mapper = mapper;
_logger = logger;
_userManager = userManager;
}

public async Task<List<SelectionProcessResposneDto>> GetAllAsync()
@@ -49,6 +51,9 @@ namespace Diligent.WebAPI.Business.Services
{
_logger.LogError($"Applicant is in the last selection level");
throw new EntityNotFoundException("Candidate came to the last selection level");
// ovde sacuvati promene i return odraditi
// da ne bi pravilo novi proces
// exception treba ukloniti
}

SelectionProcess newProcess = new SelectionProcess
@@ -57,7 +62,7 @@ namespace Diligent.WebAPI.Business.Services
SelectionLevelId = nextLevel.Id,
Status = "Čeka na zakazivanje",
ApplicantId = sp.ApplicantId,
SchedulerId = model.SchedulerId
//SchedulerId = model.SchedulerId
};
_context.SelectionProcesses.Add(newProcess);
_logger.LogInformation($"Create and add new selection process");
@@ -104,5 +109,27 @@ namespace Diligent.WebAPI.Business.Services
_logger.LogInformation($"Selection process saved to DB");
await result;
}
public async Task StatusUpdate(StatusChangeDTO model)
{
var process = await _context.SelectionProcesses.FindAsync(model.ProcessId);

if (process is null)
throw new EntityNotFoundException("Process does not exist.");

if (model.NewStatus == "Zakazan" && model.SchedulerId is not null)
{
var user = await _userManager.FindByIdAsync(model.SchedulerId.ToString());

if (user is null)
throw new EntityNotFoundException("Scheduler does not exist.");

process.SchedulerId = user.Id;
}

process.Status = model.NewStatus;
process.Date = model.Appointment;

await _context.SaveChangesAsync();
}
}
}

+ 1
- 1
Diligent.WebAPI.Contracts/DTOs/Applicant/ApplicantProcessRequestDTO.cs Просмотреть файл

@@ -4,7 +4,7 @@
{
[Required]
public int ApplicantId { get; set; }
public int SchedulerId { get; set; }
public int? SchedulerId { get; set; }
public DateTime? Appointment { get; set; }
}
}

+ 2
- 0
Diligent.WebAPI.Contracts/DTOs/SelectionProcess/SelectionProcessResposneDto.cs Просмотреть файл

@@ -1,4 +1,5 @@
using Diligent.WebAPI.Contracts.DTOs.Applicant;
using Diligent.WebAPI.Contracts.DTOs.User;

namespace Diligent.WebAPI.Contracts.DTOs.SelectionProcess
{
@@ -10,6 +11,7 @@ namespace Diligent.WebAPI.Contracts.DTOs.SelectionProcess
public DateTime? Date { get; set; }
public string? Link { get; set; }
public ApplicantViewDto Applicant { get; set; }
public UserResponseDTO Scheduler { get; set; }
public int SelectionLevelId { get; set; }
}
}

+ 18
- 0
Diligent.WebAPI.Contracts/DTOs/SelectionProcess/StatusChangeDTO.cs Просмотреть файл

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Diligent.WebAPI.Contracts.DTOs.SelectionProcess
{
public class StatusChangeDTO
{
[Required]
public string NewStatus { get; set; }
[Required]
public int ProcessId { get; set; }
public int? SchedulerId { get; set; }
public DateTime? Appointment { get; set; }
}
}

+ 7
- 0
Diligent.WebAPI.Host/Controllers/V1/SelectionProcessesController.cs Просмотреть файл

@@ -24,6 +24,13 @@ namespace Diligent.WebAPI.Host.Controllers.V1
public async Task<IActionResult> FinishSelectionProcess([FromBody] SelectionProcessCreateDto model) =>
Ok(await _selectionProcessesService.FinishSelectionProcess(model));

//[Authorize]
[HttpPost("status-update")]
public async Task<IActionResult> UpdateStatus([FromBody] StatusChangeDTO model)
{
await _selectionProcessesService.StatusUpdate(model);
return Ok("Status updated.");
}
//[HttpPost]
//public async Task<IActionResult> Create([FromBody] SelectionProcessCreateDto request)
//{

Загрузка…
Отмена
Сохранить