Imports System
Imports System.IO
Imports System.Collections
Imports System.Collections.Generic
Imports System.Runtime.Serialization
Imports ServiceStack
Imports ServiceStack.DataAnnotations
Imports MyApp.ServiceModel
Namespace Global
Namespace MyApp.ServiceModel
Public Partial Class CreatePlayer
Implements ICreateDb(Of Player)
<Validate(Validator:="NotEmpty")>
Public Overridable Property FirstName As String
Public Overridable Property LastName As String
Public Overridable Property Email As String
Public Overridable Property PhoneNumbers As List(Of Phone)
<Validate(Validator:="NotNull")>
Public Overridable Property ProfileId As Integer?
Public Overridable Property SavedLevelId As Guid?
End Class
Public Partial Class Phone
Public Overridable Property Kind As PhoneKind
Public Overridable Property Number As String
Public Overridable Property Ext As String
End Class
Public Enum PhoneKind
Home
Mobile
Work
End Enum
End Namespace
Namespace ServiceStack
<DataContract>
Public Partial Class IdResponse
<DataMember(Order:=1)>
Public Overridable Property Id As String
<DataMember(Order:=2)>
Public Overridable Property ResponseStatus As ResponseStatus
End Class
End Namespace
End Namespace
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /json/reply/CreatePlayer HTTP/1.1
Host: blazor-gallery.servicestack.net
Accept: application/json
Content-Type: application/json
Content-Length: length
{"firstName":"String","lastName":"String","email":"String","phoneNumbers":[{"kind":"Home","number":"String","ext":"String"}],"profileId":0,"savedLevelId":"00000000000000000000000000000000"}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"id":"String","responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}