Skip to Content
Building RESTful Web Services with .NET Core
book

Building RESTful Web Services with .NET Core

by Gaurav Aroraa, Tadit Dash
May 2018
Intermediate to advanced
334 pages
7h 25m
English
Packt Publishing
Content preview from Building RESTful Web Services with .NET Core

PUT – api/Carts/{id}

Now that we have added one cart record, let's move to update that record whenever a customer repeatedly hits the Add To Cart button. We already have the code that updates the quantity and price on the client-side table, so we just need to write the code to call the PUT endpoint to update the record, as follows:

function PutCart(cartItem) {  var cart =   {    Id: cartItem.attr('data-cart-id'),    Customerid: '910D4C2F-B394-4578-8D9C-7CA3FD3266E2',    Productid: cartItem.attr('data-product-id'),    Qty: cartItem.find('td.qty').html(),    Finalprice: cartItem.find('td.price').html().replace('$', '')  };  $.ajax({    url: 'http://localhost:57571/api/Carts/' + cart.Id,    type: "PUT",    contentType: "application/json",    dataType: "json",    data: JSON.stringify(cart), ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RESTful Web Services with ASP.NET Core 3

Hands-On RESTful Web Services with ASP.NET Core 3

Samuele Resca
Microservices in .NET Core

Microservices in .NET Core

Christian Horsdal Gammelgaard

Publisher Resources

ISBN: 9781788291576Supplemental Content