public class ProductRepository : IProductPrpository { #region IProductPrpository Members public IEnumerable<Product> GetAll(string ProductOption) { return Utility.GetDiscountItems(ProductOption); } public Product GetProduct(string Id) { return Utility.GetProduct(Id); } public String PostBag(Bag bagofItem) { return Utility.PostBagDiscountedItem(bagofItem); } #endregion }
@model List<MultiBuy.Models.Product> @{ ViewBag.Title = "Index"; } <h2>Items in the bag</h2> <table> <tr> <th> Item_number_option </th> <th> Option_number </th> <th> Price </th> <th> PublicationCode </th> <th> Quantity </th> </tr> @foreach (var item in Model) { <tr> <td> @item.ItemNumber</td> <td> @item.Option</td> <td> @item.Price</td> <td> @item.PublicationCode</td> <td> @item.Quantity</td> </tr> } </table> <div> <ul id="products" /> <input type="button" value="Search" onclick="find();" /> </div> @section scripts { <script> function find() { var dataJSON = '@Model'; $.ajax({ type: 'POST', url: 'http://localhost:54460/api/products?PostBag=', data: JSON.stringify(dataJSON), contentType: 'application/json; charset=utf-8', dataType: 'json' }).done(function (data) { $('#products').text(data) }); }; </script> }
config.Routes.MapHttpRoute( name: "ApiByAction", routeTemplate: "api/{controller}/{action}", defaults: new { action = "Post" } );
/api/Product/PostBag
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)