[ProducesResponseType(StatusCodes.Status500InternalServerError)] // if something unexpectedly went wrong with the database or http request/response public async Task <IActionResult> PutInvoice(int id, Furs2Feathers.Domain.Models.Invoice invoice) { if (id != invoice.InvoiceId) { return(BadRequest()); } /*_context.Entry(invoice).State = EntityState.Modified;*/ if (!await invoiceRepo.ModifyStateAsync(invoice, id)) { return(NotFound()); // if false, then modifying state failed } else { return(NoContent()); // successful put } }
[ProducesResponseType(StatusCodes.Status500InternalServerError)] // if something unexpectedly went wrong with the database or http request/response public async Task <ActionResult <Furs2Feathers.Domain.Models.Invoice> > PostInvoice(Furs2Feathers.Domain.Models.Invoice invoice) { invoiceRepo.Add(invoice); await invoiceRepo.SaveChangesAsync(); return(CreatedAtAction("GetInvoice", new { id = invoice.InvoiceId }, invoice)); }