|
|
|
@@ -111,24 +111,53 @@ namespace Diligent.WebAPI.Business.Services |
|
|
|
} |
|
|
|
public async Task StatusUpdate(StatusChangeDTO model) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"Start searching process with id = {model.ProcessId}"); |
|
|
|
var process = await _context.SelectionProcesses.FindAsync(model.ProcessId); |
|
|
|
|
|
|
|
if (process is null) |
|
|
|
{ |
|
|
|
_logger.LogError($"Process with id = {model.ProcessId} not found"); |
|
|
|
throw new EntityNotFoundException("Process does not exist."); |
|
|
|
} |
|
|
|
|
|
|
|
_logger.LogInformation($"Check which status is going to be set."); |
|
|
|
if (model.NewStatus == "Zakazan" && model.SchedulerId is not null) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"Start searching user with id = {model.SchedulerId}"); |
|
|
|
var user = await _userManager.FindByIdAsync(model.SchedulerId.ToString()); |
|
|
|
|
|
|
|
if (user is null) |
|
|
|
throw new EntityNotFoundException("Scheduler does not exist."); |
|
|
|
|
|
|
|
_logger.LogInformation($"Setting user {user.FirstName} {user.LastName} as scheduler for process with id = {model.ProcessId}"); |
|
|
|
process.SchedulerId = user.Id; |
|
|
|
} |
|
|
|
|
|
|
|
process.Status = model.NewStatus; |
|
|
|
process.Date = model.Appointment; |
|
|
|
|
|
|
|
_logger.LogInformation($"Processing changes."); |
|
|
|
await _context.SaveChangesAsync(); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task InterviewerUpdate(InterviewerUpdateDTO model) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"Start searching process with id = {model.ProcessId}"); |
|
|
|
var process = await _context.SelectionProcesses.FindAsync(model.ProcessId); |
|
|
|
|
|
|
|
if (process is null) |
|
|
|
throw new EntityNotFoundException("Process does not exist."); |
|
|
|
|
|
|
|
_logger.LogInformation($"Start searching user with id = {model.SchedulerId}"); |
|
|
|
var user = await _userManager.FindByIdAsync(model.SchedulerId.ToString()); |
|
|
|
|
|
|
|
if (user is null) |
|
|
|
throw new EntityNotFoundException("Scheduler does not exist."); |
|
|
|
|
|
|
|
_logger.LogInformation($"Setting user {user.FirstName} {user.LastName} as scheduler for process with id = {model.ProcessId}"); |
|
|
|
process.SchedulerId = user.Id; |
|
|
|
|
|
|
|
_logger.LogInformation("Processing changes..."); |
|
|
|
await _context.SaveChangesAsync(); |
|
|
|
} |
|
|
|
} |