public IActionResult Create([FromBody] SalutationDTO dto) { var Res = _Mapper.Map <Salutation>(dto); try { var salutation = _salutationRepository.SaveOrUpdateAsync(Res); return(Ok(salutation)); } catch (AppException ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> Details(int?id, SalutationDTO dto) { if (id == null) { return(NotFound()); } var salutation = await _salutationRepository.GetByIdAsync(id); var sal = _Mapper.Map <SalutationDTO>(salutation); if (salutation == null) { return(NotFound()); } return(Ok(sal)); }
public IActionResult Update(int id, [FromBody] SalutationDTO dto) { // map dto to entity and set id var salutation = _Mapper.Map <Salutation>(dto); salutation.Id = id; try { // save _salutationRepository.UpdateAsync(salutation, id); return(Ok()); } catch (AppException ex) { // return error message if there was an exception return(BadRequest(ex.Message)); } }