July 2015
Intermediate to advanced
1300 pages
87h 27m
English
The next step is to implement CRUD operations. For queries, methods in the OData service must match HTTP verbs. Adding a new object through an OData service is done via the POST verb. So you need to replace the PostCustomer method with the following:
<ResponseType(GetType(Customer))>Async Function Post(ByVal customer As Customer) _ As Task(Of IHttpActionResult) If Not ModelState.IsValid Then Return BadRequest(ModelState) End If db.Customers.Add(customer) Try Await db.SaveChangesAsync() Catch ex As DbUpdateException If (CustomerExists(customer.CustomerID)) Then Return Conflict() Else Throw End If End Try Return ...