MyApp

<back to all web services

QueryPlayer

Game
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 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

        Public Partial Class Player
            Inherits AuditBase
            Public Overridable Property Id As Integer
            <Required>
            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) = New List(Of Phone)
            Public Overridable Property GameItems As List(Of PlayerGameItem) = New List(Of PlayerGameItem)
            Public Overridable Property Profile As Profile
            Public Overridable Property ProfileId As Integer
            Public Overridable Property SavedLevelId As Guid
            Public Overridable Property RowVersion As UInt64
        End Class

        Public Partial Class PlayerGameItem
            Public Overridable Property Id As Integer
            <References(GetType(Player))>
            Public Overridable Property PlayerId As Integer

            <References(GetType(GameItem))>
            Public Overridable Property GameItemName As String
        End Class

        Public Enum PlayerRegion
            Africa = 1
            Americas = 2
            Asia = 3
            Australasia = 4
            Europe = 5
        End Enum

        Public Enum PlayerRole
            Leader
            Player
            NonPlayer
        End Enum

        Public Partial Class Profile
            Inherits AuditBase
            Public Overridable Property Id As Integer
            Public Overridable Property Role As PlayerRole
            Public Overridable Property Region As PlayerRegion
            Public Overridable Property Username As String
            Public Overridable Property HighScore As Long
            Public Overridable Property GamesPlayed As Long
            Public Overridable Property Energy As Integer
            Public Overridable Property ProfileUrl As String
            Public Overridable Property CoverUrl As String
            Public Overridable Property Meta As Dictionary(Of String, String)
        End Class

        Public Partial Class QueryPlayer
            Inherits QueryDb(Of Player)
        End Class

        Public Partial Class Todo
            Public Overridable Property Id As Long
            Public Overridable Property Text As String
            Public Overridable Property IsFinished As Boolean
        End Class
    End Namespace

    Namespace ServiceStack

        <DataContract>
        Public Partial Class AuditBase
            <DataMember(Order:=1)>
            Public Overridable Property CreatedDate As Date

            <DataMember(Order:=2)>
            <Required>
            Public Overridable Property CreatedBy As String

            <DataMember(Order:=3)>
            Public Overridable Property ModifiedDate As Date

            <DataMember(Order:=4)>
            <Required>
            Public Overridable Property ModifiedBy As String

            <DataMember(Order:=5)>
            Public Overridable Property DeletedDate As Date?

            <DataMember(Order:=6)>
            Public Overridable Property DeletedBy As String
        End Class

        <DataContract>
        Public Partial Class QueryBase
            <DataMember(Order:=1)>
            Public Overridable Property Skip As Integer?

            <DataMember(Order:=2)>
            Public Overridable Property Take As Integer?

            <DataMember(Order:=3)>
            Public Overridable Property OrderBy As String

            <DataMember(Order:=4)>
            Public Overridable Property OrderByDesc As String

            <DataMember(Order:=5)>
            Public Overridable Property Include As String

            <DataMember(Order:=6)>
            Public Overridable Property Fields As String

            <DataMember(Order:=7)>
            Public Overridable Property Meta As Dictionary(Of String, String)
        End Class

        Public Partial Class QueryDb(Of T)
            Inherits QueryBase
        End Class

        <DataContract>
        Public Partial Class QueryResponse(Of T)
            <DataMember(Order:=1)>
            Public Overridable Property Offset As Integer

            <DataMember(Order:=2)>
            Public Overridable Property Total As Integer

            <DataMember(Order:=3)>
            Public Overridable Property Results As List(Of Todo)

            <DataMember(Order:=4)>
            Public Overridable Property Meta As Dictionary(Of String, String)

            <DataMember(Order:=5)>
            Public Overridable Property ResponseStatus As ResponseStatus
        End Class
    End Namespace
End Namespace

VB.NET QueryPlayer DTOs

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

HTTP + JSON

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /json/reply/QueryPlayer HTTP/1.1 
Host: blazor-gallery.servicestack.net 
Accept: application/json
Content-Type: application/json
Content-Length: length

{"skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length

{"offset":0,"total":0,"results":[{"id":0,"firstName":"String","lastName":"String","email":"String","phoneNumbers":[{"kind":"Home","number":"String","ext":"String"}],"gameItems":[{"id":0,"playerId":0,"gameItemName":"String"}],"profile":{"id":0,"role":"Leader","region":"Africa","username":"String","highScore":0,"gamesPlayed":0,"energy":0,"profileUrl":"String","coverUrl":"String","meta":{"String":"String"},"createdDate":"0001-01-01T00:00:00","createdBy":"String","modifiedDate":"0001-01-01T00:00:00","modifiedBy":"String","deletedDate":"0001-01-01T00:00:00","deletedBy":"String"},"profileId":0,"savedLevelId":"00000000-0000-0000-0000-000000000000","rowVersion":0,"createdDate":"0001-01-01T00:00:00","createdBy":"String","modifiedDate":"0001-01-01T00:00:00","modifiedBy":"String","deletedDate":"0001-01-01T00:00:00","deletedBy":"String"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}