瀏覽代碼

Merge branch 'feature/2183_interviewer_selection_methods' of Neca/HRCenter into BE_dev

pull/122/head
safet.purkovic 3 年之前
父節點
當前提交
9684bea2ba

+ 1
- 0
Diligent.WebAPI.Business/Services/Interfaces/ISelectionProcessService.cs 查看文件

Task<bool> FinishSelectionProcess(SelectionProcessCreateDto model); Task<bool> FinishSelectionProcess(SelectionProcessCreateDto model);
Task<List<SelectionLevelInfoDto>> GetCountByLevels(List<string> statuses); Task<List<SelectionLevelInfoDto>> GetCountByLevels(List<string> statuses);
Task UpdateSelectionProcessStatusAsync(int id, SelectionProcessUpdateStatusDto selectionProcessUpdateStatusDto); Task UpdateSelectionProcessStatusAsync(int id, SelectionProcessUpdateStatusDto selectionProcessUpdateStatusDto);
Task StatusUpdate(StatusChangeDTO model);
} }
} }

+ 2
- 0
Diligent.WebAPI.Business/Services/SelectionLevelService.cs 查看文件

var fromDb = await _context.SelectionLevels var fromDb = await _context.SelectionLevels
.Include(sl => sl.SelectionProcesses) .Include(sl => sl.SelectionProcesses)
.ThenInclude(sp => sp.Applicant) .ThenInclude(sp => sp.Applicant)
.Include(sl => sl.SelectionProcesses)
.ThenInclude(sp => sp.Scheduler)
.ToListAsync(); .ToListAsync();


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

+ 29
- 2
Diligent.WebAPI.Business/Services/SelectionProcessService.cs 查看文件

{ {
private readonly DatabaseContext _context; private readonly DatabaseContext _context;
private readonly IMapper _mapper; private readonly IMapper _mapper;
private readonly UserManager<User> _userManager;
private readonly ILogger<SelectionProcessService> _logger; 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; _context = context;
_mapper = mapper; _mapper = mapper;
_logger = logger; _logger = logger;
_userManager = userManager;
} }


public async Task<List<SelectionProcessResposneDto>> GetAllAsync() public async Task<List<SelectionProcessResposneDto>> GetAllAsync()
{ {
_logger.LogError($"Applicant is in the last selection level"); _logger.LogError($"Applicant is in the last selection level");
throw new EntityNotFoundException("Candidate came to 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 SelectionProcess newProcess = new SelectionProcess
SelectionLevelId = nextLevel.Id, SelectionLevelId = nextLevel.Id,
Status = "Čeka na zakazivanje", Status = "Čeka na zakazivanje",
ApplicantId = sp.ApplicantId, ApplicantId = sp.ApplicantId,
SchedulerId = model.SchedulerId
//SchedulerId = model.SchedulerId
}; };
_context.SelectionProcesses.Add(newProcess); _context.SelectionProcesses.Add(newProcess);
_logger.LogInformation($"Create and add new selection process"); _logger.LogInformation($"Create and add new selection process");
_logger.LogInformation($"Selection process saved to DB"); _logger.LogInformation($"Selection process saved to DB");
await result; 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 查看文件

{ {
[Required] [Required]
public int ApplicantId { get; set; } public int ApplicantId { get; set; }
public int SchedulerId { get; set; }
public int? SchedulerId { get; set; }
public DateTime? Appointment { get; set; } public DateTime? Appointment { get; set; }
} }
} }

+ 2
- 0
Diligent.WebAPI.Contracts/DTOs/SelectionProcess/SelectionProcessResposneDto.cs 查看文件

using Diligent.WebAPI.Contracts.DTOs.Applicant; using Diligent.WebAPI.Contracts.DTOs.Applicant;
using Diligent.WebAPI.Contracts.DTOs.User;


namespace Diligent.WebAPI.Contracts.DTOs.SelectionProcess namespace Diligent.WebAPI.Contracts.DTOs.SelectionProcess
{ {
public DateTime? Date { get; set; } public DateTime? Date { get; set; }
public string? Link { get; set; } public string? Link { get; set; }
public ApplicantViewDto Applicant { get; set; } public ApplicantViewDto Applicant { get; set; }
public UserResponseDTO Scheduler { get; set; }
public int SelectionLevelId { get; set; } public int SelectionLevelId { get; set; }
} }
} }

+ 18
- 0
Diligent.WebAPI.Contracts/DTOs/SelectionProcess/StatusChangeDTO.cs 查看文件

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 查看文件

public async Task<IActionResult> FinishSelectionProcess([FromBody] SelectionProcessCreateDto model) => public async Task<IActionResult> FinishSelectionProcess([FromBody] SelectionProcessCreateDto model) =>
Ok(await _selectionProcessesService.FinishSelectionProcess(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] //[HttpPost]
//public async Task<IActionResult> Create([FromBody] SelectionProcessCreateDto request) //public async Task<IActionResult> Create([FromBody] SelectionProcessCreateDto request)
//{ //{

Loading…
取消
儲存