public IActionResult CreateMayor([FromBody] MayorDetailsDto mayorDto) { try { var entityMayor = _mapper.Map <Mayor>(mayorDto); _mayorRepository.AddMayor(entityMayor); _mayorRepository.Save(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult UpdateMayor([FromBody] MayorDetailsDto mayorDto, int mayorId) { try { var entityMayor = _mayorRepository.GetMayor(mayorId); if (entityMayor == null) { return(NotFound()); } _mapper.Map(mayorDto, entityMayor); _mayorRepository.UpdateMayor(mayorId, entityMayor); _mayorRepository.Save(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }