public Applicant GetById(int id) { Applicant applicant = _ApplicantRepository.GetById(id); if (applicant == null) { throw new Exception(string.Format("No applicant has been found by this id : {0}", id)); } return(applicant); }
public async Task <ApplicantDto> GetById(int applicantId) { try { var applicant = await _applicantRepository.GetById(applicantId); var applicantDto = new ApplicantDto() { Id = applicant.Id, Name = applicant.Name, FamilyName = applicant.FamilyName, Address = applicant.Address, CountryOfOrigin = applicant.CountryOfOrigin, EmailAddress = applicant.EmailAddress, Age = applicant.Age, Hired = applicant.Hired, }; return(applicantDto); } catch (Exception ex) { Console.WriteLine(ex); throw; } }
public ApplicantModel GetById(int id) { var applicant = _repository.GetById(id); if (applicant != null) { var result = new ApplicantModel { ID = applicant.ID, Name = applicant.Name, FamilyName = applicant.FamilyName, Address = applicant.Address, CountryOfOrigin = applicant.CountryOfOrigin, EMailAddress = applicant.EMailAddress, Age = applicant.Age, Hired = applicant.Hired }; return(result); } return(null); }
public async Task <ApplicantGet> GetById(int id) { if (id <= 0) { throw new Exception("Id cannot be null or empty"); } Applicant applicant = await _applicantRepository.GetById(id); if (applicant == null) { throw new Exception("Applicant with this id not found"); } return(_mapper.Map <ApplicantGet>(applicant)); }
public async Task <Applicant> GetById(int id) { return(await _repository.GetById(id)); }