瀏覽代碼

Modified endpoint from get to post

pull/43/head
Safet Purkovic 3 年之前
父節點
當前提交
f5a9c58d73

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

@@ -39,6 +39,7 @@ namespace Diligent.WebAPI.Business.Services
{
var applicant = await _context.Applicants
.Include(a => a.SelectionProcesses).ThenInclude(sp => sp.SelectionLevel)
.Include(a => a.SelectionProcesses).ThenInclude(sp => sp.Scheduler)
.FirstOrDefaultAsync(a => a.ApplicantId == id);

if (applicant is null)

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

@@ -9,7 +9,7 @@ namespace Diligent.WebAPI.Business.Services.Interfaces
Task DeleteAsync(int id);
Task<List<SelectionProcessResposneDto>> GetAllAsync();
Task<SelectionProcessResposneDto> GetByIdAsync(int id);
Task<bool> FinishSelectionProcess(int id);
Task<bool> FinishSelectionProcess(SelectionProcessCreateDto model);
Task UpdateAsync(int id, SelectionProcessCreateDto model);
}
}

+ 5
- 4
Diligent.WebAPI.Business/Services/SelectionProcessService.cs 查看文件

@@ -60,9 +60,9 @@ namespace Diligent.WebAPI.Business.Services
await _context.SaveChangesAsync();
}

public async Task<bool> FinishSelectionProcess(int id)
public async Task<bool> FinishSelectionProcess(SelectionProcessCreateDto model)
{
var sp = await _context.SelectionProcesses.FindAsync(id);
var sp = await _context.SelectionProcesses.FindAsync(model.Id);

if (sp is null)
throw new EntityNotFoundException("Selection process not found");
@@ -76,10 +76,11 @@ namespace Diligent.WebAPI.Business.Services

SelectionProcess newProcess = new SelectionProcess
{
Name = sp.Name,
Name = model.Name,
SelectionLevelId = nextLevel.Id,
Status = "Čeka na zakazivanje",
ApplicantId = sp.ApplicantId
ApplicantId = sp.ApplicantId,
SchedulerId = model.SchedulerId
};
_context.SelectionProcesses.Add(newProcess);


+ 4
- 3
Diligent.WebAPI.Contracts/DTOs/SelectionProcess/SelectionProcessCreateDto.cs 查看文件

@@ -2,11 +2,12 @@
{
public class SelectionProcessCreateDto
{
public string Name { get; set; }
public string Status { get; set; }
public int Id { get; set; }
public string? Name { get; set; }
public string? Status { get; set; }
public DateTime? Date { get; set; }
public string? Link { get; set; }
public int? SchedulerId { get; set; }
public int SchedulerId { get; set; }
public int SelectionLevelId { get; set; }
public int ApplicantId { get; set; }
}

+ 1
- 1
Diligent.WebAPI.Contracts/DTOs/SelectionProcess/SelectionProcessResposneWithoutApplicantDto.cs 查看文件

@@ -8,7 +8,7 @@ namespace Diligent.WebAPI.Contracts.DTOs.SelectionProcess
public string Status { get; set; }
public DateTime? Date { get; set; }
public string? Link { get; set; }
public UserResponseDTO User { get; set; }
public UserResponseDTO Scheduler { get; set; }
public SelectionLevelResposneDto SelectionLevel { get; set; }
}
}

+ 9
- 9
Diligent.WebAPI.Host/Controllers/V1/SelectionProcessesController.cs 查看文件

@@ -19,16 +19,16 @@ namespace Diligent.WebAPI.Host.Controllers.V1
public async Task<IActionResult> GetAll() =>
Ok(await _selectionProcessesService.GetAllAsync());

[HttpGet("{id}")]
public async Task<IActionResult> FinishSelectionProcess([FromRoute] int id) =>
Ok(await _selectionProcessesService.FinishSelectionProcess(id));

[HttpPost]
public async Task<IActionResult> Create([FromBody] SelectionProcessCreateDto request)
{
await _selectionProcessesService.CreateAsync(request);
return StatusCode((int)HttpStatusCode.Created);
}
public async Task<IActionResult> FinishSelectionProcess([FromBody] SelectionProcessCreateDto model) =>
Ok(await _selectionProcessesService.FinishSelectionProcess(model));

//[HttpPost]
//public async Task<IActionResult> Create([FromBody] SelectionProcessCreateDto request)
//{
// await _selectionProcessesService.CreateAsync(request);
// return StatusCode((int)HttpStatusCode.Created);
//}

[HttpPut("{id}")]
public async Task<IActionResult> Update([FromBody] SelectionProcessCreateDto request, [FromRoute] int id)

Loading…
取消
儲存