// PUT: api/BonAPayer/5 public BonAPayerDto Put([FromBody] BonAPayerDto bonAPayerDto) { if (ModelState.IsValid) { return(this.service.Update(bonAPayerDto)); } return(null); }
public BonAPayerDto Insert(BonAPayerDto bonAPayerDto) { BonAPayer bonAPayer = this.repository.Insert(this.mapper.Map <BonAPayer>(bonAPayerDto)); Reglement reglementToUpdate = this.reglementRepository.GetById(bonAPayerDto.IdReglement); reglementToUpdate.IdBonAPayer = bonAPayer.Id; this.reglementRepository.Update(reglementToUpdate); return(this.mapper.Map <BonAPayerDto>(bonAPayer)); }
public BonAPayerDto Update(BonAPayerDto bonAPayerDto) { BonAPayer toUpdate = this.GetById(bonAPayerDto.Id); toUpdate.DateSignature = bonAPayerDto.DateSignature; toUpdate.DateValidation = bonAPayerDto.DateValidation; toUpdate.EstRegle = bonAPayerDto.EstRegle; toUpdate.MontantRetenu = bonAPayerDto.MontantRetenu; toUpdate.MontantTotalEcheance = bonAPayerDto.MontantTotalEcheance; toUpdate.NetAPayer = bonAPayerDto.NetAPayer; toUpdate.ValiderPar = bonAPayerDto.ValiderPar; foreach (var item in toUpdate.Reglement.FirstOrDefault().ReglementFacture) { Facture facture = this.facturesRepository.GetById(item.IdFacture); facture.MontantRegle = item.MontantTotale; facture.MontantReste = facture.MontantTotale - facture.MontantRegle; this.facturesRepository.Update(facture); } return(this.mapper.Map <BonAPayerDto>(this.repository.Update(toUpdate))); }