#103 implemented selection process initialization

Fusionado
safet.purkovic fusionados 2 commits de feature/1999_initial_interview_be en BE_dev hace 3 años

+ 1
- 0
Diligent.WebAPI.Business/MappingProfiles/ApplicantMappingProfile.cs Ver fichero

@@ -11,6 +11,7 @@ namespace Diligent.WebAPI.Business.MappingProfiles
CreateMap<Applicant, AdApplicantViewDto>();
CreateMap<Applicant, ApplicantScheduleViewDto>();
CreateMap<Applicant, PatternApplicantViewDto>();
CreateMap<Applicant, ApplicantOptionsDTO>();
#endregion

#region DTOs to Models

+ 34
- 0
Diligent.WebAPI.Business/Services/ApplicantService.cs Ver fichero

@@ -111,6 +111,40 @@
return result;
}

public async Task<List<ApplicantOptionsDTO>> GetOptions()
{
var res = await _context.Applicants.ToListAsync();
return _mapper.Map<List<ApplicantOptionsDTO>>(res);
}

public async Task<ServiceResponseDTO<object>> InitializeProcess(ApplicantProcessRequestDTO model)
{
var applicant = await _context.Applicants.Include(n => n.SelectionProcesses).Where(n=> n.ApplicantId ==model.ApplicantId).FirstOrDefaultAsync();

if (applicant == null)
return new ServiceResponseDTO<object>
{
IsError = true,
ErrorMessage = "Applicant does not exist."
};

applicant.SelectionProcesses.Add(new SelectionProcess
{
Name = StringGenerator.GenerateRandomPassword(),
SchedulerId = model.SchedulerId,
SelectionLevelId = 1,
Status = model.Appointment != null ? "Zakazan" : "Čeka na zakazivanje",
Date = model.Appointment
});

await _context.SaveChangesAsync();

return new ServiceResponseDTO<object>
{
Data = true
};
}

//public async Task CreateApplicant(ApplicantCreateDto applicantCreateDto)
//{
// var applicant = _mapper.Map<Applicant>(applicantCreateDto);

+ 4
- 0
Diligent.WebAPI.Business/Services/Interfaces/IApplicantService.cs Ver fichero

@@ -1,4 +1,6 @@

using Diligent.WebAPI.Contracts.DTOs.Applicant;

namespace Diligent.WebAPI.Business.Services.Interfaces
{
public interface IApplicantService
@@ -8,6 +10,8 @@ namespace Diligent.WebAPI.Business.Services.Interfaces
Task<ApplicantViewDto> GetById(int id);
Task<ApplicantViewDto> GetApplicantWithSelectionProcessesById(int id);
Task DeleteApplicant(int id);
Task<List<ApplicantOptionsDTO>> GetOptions();
Task<ServiceResponseDTO<object>> InitializeProcess(ApplicantProcessRequestDTO model);
//Task CreateApplicant(ApplicantCreateDto applicantCreateDto);
//Task UpdateApplicant(int id, ApplicantUpdateDto applicantUpdateDto);
}

+ 9
- 0
Diligent.WebAPI.Contracts/DTOs/Applicant/AplicantOptionsDTO.cs Ver fichero

@@ -0,0 +1,9 @@
namespace Diligent.WebAPI.Contracts.DTOs.Applicant
{
public class ApplicantOptionsDTO
{
public int ApplicantId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
}

+ 10
- 0
Diligent.WebAPI.Contracts/DTOs/Applicant/ApplicantProcessRequestDTO.cs Ver fichero

@@ -0,0 +1,10 @@
namespace Diligent.WebAPI.Contracts.DTOs.Applicant
{
public class ApplicantProcessRequestDTO
{
[Required]
public int ApplicantId { get; set; }
public int SchedulerId { get; set; }
public DateTime? Appointment { get; set; }
}
}

+ 13
- 0
Diligent.WebAPI.Host/Controllers/V1/ApplicantsController.cs Ver fichero

@@ -43,5 +43,18 @@ namespace Diligent.WebAPI.Host.Controllers.V1
return Ok(await _applicantService.GetApplicantWithSelectionProcessesById(id));
}

[HttpGet("options")]
public async Task<IActionResult> GetOptions()
{
return Ok(await _applicantService.GetOptions());
}

[HttpPost("selection-init")]
public async Task<IActionResult> InitSelection(ApplicantProcessRequestDTO model)
{
await _applicantService.InitializeProcess(model);
return Ok();
}

}
}

Cargando…
Cancelar
Guardar