public async Task <IActionResult> PostRepresentative(RepresentativeDto representativeDto) { try { var representative = _mapper.Map <Representante>(representativeDto); await _unitOfWork.RepresentativeRepository.Add(representative); await _unitOfWork.SaveChangesAsync(); var response = new ApiResponse <string>("Representative saved"); return(Ok(response)); } catch (Exception) { return(BadRequest()); } }
public async Task <IActionResult> PutRepresentative(int id, RepresentativeDto representativeDto) { try { var user = _mapper.Map <Representante>(representativeDto); user.IdRepresentante = id; var result = await _representativeService.UpdateRepresentative(user); var response = new ApiResponse <string>("Representative could not be updated"); if (result) { response.Data = "Representative updated"; } return(Ok(response)); } catch (Exception) { return(BadRequest()); } }