public async Task <Payement> PostPayement(PayementViewModel payement) { try { var p = _mapper.Map <Payement>(payement); await _payementRepository.InsertAsync(p); await _payementRepository.SaveAsync(); foreach (PayementEnrollementViewModel payementenrollementviewmodel in payement.PayementEnrollementModels) { var pe = _mapper.Map <PayementEnrollement>(payementenrollementviewmodel); pe.PayementId = p.Id; await _payementEnrollementRepository.InsertAsync(pe); await _payementEnrollementRepository.SaveAsync(); } foreach (ModaliteViewModel modalitesviewmodel in payement.ModaliteModels) { var m = _mapper.Map <Modalite>(modalitesviewmodel); m.PayementId = p.Id; await _modaliteRepository.InsertAsync(m); await _modaliteRepository.SaveAsync(); } return(p); } catch (Exception e) { throw e; } }