public async Task <ActionResult <Applicant> > DeleteApplicant(int id) { try { var applicantToDelete = await applicantRepository.GetApplicant(id); if (applicantToDelete == null) { Log.Error($"{Section.GetValue<string>("NotFound")}[object=Applicant; id={id}]"); return(NotFound($"Applicant with id= {id} not found")); } Log.Information($"[object=Applicant; id={id}] has been deleted"); Log.Debug($"Deleted object: [{applicantToDelete}]"); return(await applicantRepository.DeleteApplicantAsync(id)); } catch (Exception err) { Log.Error($"Exception occured: [{err}]\nStatusCode:{Code500}"); return(StatusCode(Code500, $"Exception occured: {err}\n{Section.GetValue<string>("DeletingError")}")); } }
public async Task <Unit> Handle(DeleteApplicantCommand request, CancellationToken cancellationToken) { await _applicantRepository.DeleteApplicantAsync(request.Id); return(Unit.Value); }