Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a simple admin service


ServiceStack's heavy use of DTOs in the form of Plain Old CLR Objects (POCOs) enables developers to expose data in very simple, elegant ways. A common service you might want to add to your API or web services is an admin interface where you might want to list all your users to administrators. In this recipe, we will see how, using various parts of the ServiceStack framework, this can be achieved in a very readable and concise way.

Getting ready

First, we'll need a project with ServiceStack references to be up and running. To do this, please see Creating a ServiceStack solution with VisualStudio and NuGet in Appendix A, Getting Started.

We are also going to have some basic authentication, settings, and OrmLite set up to work in our application, as follows:

var dbFactory = new OrmLiteConnectionFactory(
                "~/App_Data/db.sqlite".MapHostAbsolutePath(), SqliteDialect.Provider);
container.Register<IDbConnectionFactory>(dbFactory);
var userRep = new...