public void Post([FromBody] FactureDTO factureDTO) { if (ModelState.IsValid) { _data.Add(factureDTO.ToFacture()); } }
public ActionResult <Invoice> Post([FromBody] Invoice newInvoice) { if (ModelState.IsValid) { _data.Add(newInvoice); return(Created($"invoices/{newInvoice.Reference}", newInvoice)); } else { return(BadRequest(ModelState.Values)); } }
public ActionResult <Facture> CreateFacture([FromBody] Facture nouvelleFacture) { if (ModelState.IsValid) { _data.Add(nouvelleFacture); return(nouvelleFacture); } else { return(BadRequest("Facture non valide")); } }
public ActionResult <Invoice> CreateInvoice([FromQuery] Invoice newInvoice) { if (ModelState.IsValid) { // TODO : Ajouter la nouvelle facture à la collection /*return Created($"invoices/{newInvoice.Reference}", newInvoice);*/ _data.Add(newInvoice); return(newInvoice); } else { return(BadRequest("Invoice is not valid")); } }