public ServiceResponseDTO <ApplicantLevelDTO> SaveApplicantLevel(ApplicantLevelDTO dto) { var result = new ServiceResponseDTO <ApplicantLevelDTO>(true, new ApplicantLevelDTO(), new List <string>()); try { var request = _mapper.Map <ApplicantLevel>(dto); ApplicantLevel model; if (dto.Id == 0) { model = _applicantLevelRepo.CreateApplicantLevel(request); } else { model = _applicantLevelRepo.UpdateApplicantLevel(request); } result.ResponseData = _mapper.Map <ApplicantLevelDTO>(model); } catch (Exception ex) { result.Success = false; result.Errors.Add(ex.Message); } return(result); }
public ServiceResponseDTO <ApplicantLevelDTO> Update([FromBody] ApplicantLevelDTO dto) { var response = new ServiceResponseDTO <ApplicantLevelDTO>(false, new ApplicantLevelDTO(), new List <string>()); try { response = _applicantLevelSvc.SaveApplicantLevel(dto); } catch (Exception ex) { response.Errors.Add(ex.Message); } return(response); }
public ServiceResponseDTO <ApplicantLevelDTO> Post([FromBody] ApplicantLevelDTO dto) { var response = new ServiceResponseDTO <ApplicantLevelDTO>(false, new ApplicantLevelDTO(), new List <string>()); try { if (dto.Id == 0) { response = _applicantLevelSvc.SaveApplicantLevel(dto); } else { response.Errors.Add("This ID already exists."); } } catch (Exception ex) { response.Errors.Add(ex.Message); } return(response); }