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

implemented selection process initialization

feature/1999_initial_interview_be
meris.ahmatovic 3 лет назад
Родитель
Сommit
64c30b7b8d

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

CreateMap<Applicant, AdApplicantViewDto>(); CreateMap<Applicant, AdApplicantViewDto>();
CreateMap<Applicant, ApplicantScheduleViewDto>(); CreateMap<Applicant, ApplicantScheduleViewDto>();
CreateMap<Applicant, PatternApplicantViewDto>(); CreateMap<Applicant, PatternApplicantViewDto>();
CreateMap<Applicant, ApplicantOptionsDTO>();
#endregion #endregion


#region DTOs to Models #region DTOs to Models

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

return result; 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) //public async Task CreateApplicant(ApplicantCreateDto applicantCreateDto)
//{ //{
// var applicant = _mapper.Map<Applicant>(applicantCreateDto); // var applicant = _mapper.Map<Applicant>(applicantCreateDto);

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

 
using Diligent.WebAPI.Contracts.DTOs.Applicant;

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

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

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 Просмотреть файл

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 Просмотреть файл

return Ok(await _applicantService.GetApplicantWithSelectionProcessesById(id)); 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(model);
}

} }
} }

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