Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed lib/ServiceStack.Common.dll
Binary file not shown.
Binary file removed lib/ServiceStack.Interfaces.dll
Binary file not shown.
Binary file removed lib/ServiceStack.OrmLite.SqlServer.dll
Binary file not shown.
Binary file removed lib/ServiceStack.OrmLite.Sqlite.dll
Binary file not shown.
Binary file removed lib/ServiceStack.OrmLite.dll
Binary file not shown.
Binary file removed lib/ServiceStack.Razor.dll
Binary file not shown.
11 changes: 0 additions & 11 deletions lib/ServiceStack.Razor.dll.config

This file was deleted.

Binary file removed lib/ServiceStack.RazorEngine.dll
Binary file not shown.
11 changes: 0 additions & 11 deletions lib/ServiceStack.RazorEngine.dll.config

This file was deleted.

Binary file removed lib/ServiceStack.Redis.dll
Binary file not shown.
Binary file removed lib/ServiceStack.ServiceInterface.dll
Binary file not shown.
Binary file removed lib/ServiceStack.Text.dll
Binary file not shown.
Binary file removed lib/ServiceStack.dll
Binary file not shown.
48 changes: 24 additions & 24 deletions src/Backbone.Todos/Backbone.Todos.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,26 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ServiceStack, Version=2.0.7.20458, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\ServiceStack.dll</HintPath>
<Reference Include="ServiceStack, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Common, Version=1.0.4095.20455, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
<Reference Include="ServiceStack.Common, Version=3.9.9.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Common.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces, Version=1.0.4095.20451, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\ServiceStack.Interfaces.dll</HintPath>
<Reference Include="ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Redis, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\ServiceStack.Redis.dll</HintPath>
<Reference Include="ServiceStack.OrmLite.SqlServer">
<HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.9\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.ServiceInterface, Version=1.0.4080.41519, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\ServiceStack.ServiceInterface.dll</HintPath>
<Reference Include="ServiceStack.Redis, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Redis.3.9.11\lib\net35\ServiceStack.Redis.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text">
<HintPath>..\..\lib\ServiceStack.Text.dll</HintPath>
<Reference Include="ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.ServiceInterface.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ServiceStack.Text.3.9.11\lib\net35\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -62,7 +60,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="default.htm" />
<Content Include="destroy.png" />
<Content Include="Content\Images\destroy.png" />
<Content Include="docs\backbone-localstorage.html" />
<Content Include="docs\backbone.html" />
<Content Include="docs\docco.css" />
Expand All @@ -80,11 +78,11 @@
<Content Include="docs\images\tzigla.png" />
<Content Include="docs\todos.html" />
<Content Include="Global.asax" />
<Content Include="js\backbone.js" />
<Content Include="js\jquery-1.5.js" />
<Content Include="js\underscore-1.1.5.js" />
<Content Include="todos.css" />
<Content Include="todos.js" />
<Content Include="Scripts\backbone.js" />
<Content Include="Scripts\jquery-1.5.js" />
<Content Include="Scripts\underscore-1.1.5.js" />
<Content Include="Content\Css\todos.css" />
<Content Include="Scripts\todos.js" />
<Content Include="Web.config" />
</ItemGroup>
<ItemGroup>
Expand All @@ -93,7 +91,9 @@
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<ProjectExtensions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ html {
cursor: pointer;
width: 20px;
height: 20px;
background: url(destroy.png) no-repeat 0 0;
background: url(../Images/destroy.png) no-repeat 0 0;
}
#todo-list li:hover .todo-destroy {
display: block;
Expand Down
158 changes: 94 additions & 64 deletions src/Backbone.Todos/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,83 +2,113 @@
using ServiceStack.Redis;
using ServiceStack.ServiceInterface;
using ServiceStack.WebHost.Endpoints;
using Funq;
using ServiceStack.Text;

//The entire C# source code for the ServiceStack + Redis TODO REST backend. There is no other .cs :)
namespace Backbone.Todos
{
//REST Resource DTO
public class Todo
{
public long Id { get; set; }
public string Content { get; set; }
public int Order { get; set; }
public bool Done { get; set; }
}
/// <summary>
/// Define your ServiceStack web service request (i.e. Request DTO).
/// </summary>
public class Todo
{
public long Id { get; set; }
public string Content { get; set; }
public int Order { get; set; }
public bool Done { get; set; }
}

//Todo REST Service implementation
public class TodoService : RestServiceBase<Todo>
{
public IRedisClientsManager RedisManager { get; set; } //Injected by IOC
/// <summary>
/// Create your ServiceStack rest-ful web service implementation.
/// </summary>
public class TodoService : RestServiceBase<Todo>
{
/// <summary>
/// Gets or sets the Redis Manager. The built-in IoC used with ServiceStack autowires this property.
/// </summary>
public IRedisClientsManager RedisManager { get; set; }

public override object OnGet(Todo request)
{
//return single todo
if (request.Id != default(long))
return RedisManager.ExecAs<Todo>(r => r.GetById(request.Id));
public override object OnGet(Todo todo)
{
//Return a single Todo if the id is provided.
if (todo.Id != default(long))
{
return RedisManager.ExecAs<Todo>(r => r.GetById(todo.Id));
}

//return all todos
return RedisManager.ExecAs<Todo>(r => r.GetAll());
}
//Return all Todos items.
return RedisManager.ExecAs<Todo>(r => r.GetAll());
}

//Handles creaing a new and updating existing todo
public override object OnPost(Todo todo)
{
RedisManager.ExecAs<Todo>(r => {
//Get next id for new todo
if (todo.Id == default(long)) todo.Id = r.GetNextSequence();
r.Store(todo);
});
return todo;
}
/// <summary>
/// Handles creating and updating the Todo items.
/// </summary>
/// <param name="todo">The todo.</param>
/// <returns></returns>
public override object OnPost(Todo todo)
{
RedisManager.ExecAs<Todo>(r =>
{
//Get next id for new todo
if (todo.Id == default(long)) todo.Id = r.GetNextSequence();
r.Store(todo);
});
return todo;
}

public override object OnPut(Todo request)
{
return OnPost(request);
}
/// <summary>
/// Handles creating and updating the Todo items.
/// </summary>
/// <param name="todo">The todo.</param>
/// <returns></returns>
public override object OnPut(Todo todo)
{
return OnPost(todo);
}

public override object OnDelete(Todo request)
{
RedisManager.ExecAs<Todo>(r => r.DeleteById(request.Id));
return null;
}
}
public override object OnDelete(Todo todo)
{
RedisManager.ExecAs<Todo>(r => r.DeleteById(todo.Id));
return null;
}
}

//Configure ServiceStack.NET web service host
public class AppHost : AppHostBase
{
//Tell ServiceStack the name and where to find your web services
public AppHost() : base("Backbone.js TODO", typeof(TodoService).Assembly) { }
/// <summary>
/// Create your ServiceStack web service application with a singleton AppHost.
/// </summary>
public class ToDoAppHost : AppHostBase
{
/// <summary>
/// Initializes a new instance of your ServiceStack application, with the specified name and assembly containing the services.
/// </summary>
public ToDoAppHost() : base("Backbone.js TODO", typeof(TodoService).Assembly) { }

public override void Configure(Funq.Container container)
{
//Set JSON web services to return idiomatic JSON camelCase properties
ServiceStack.Text.JsConfig.EmitCamelCaseNames = true;
/// <summary>
/// Configure the container with the necessary routes for your ServiceStack application.
/// </summary>
/// <param name="container">The built-in IoC used with ServiceStack.</param>
public override void Configure(Container container)
{
//Configure ServiceStack Json web services to return idiomatic Json camelCase properties.
JsConfig.EmitCamelCaseNames = true;

//Register Redis factory in Funq IOC
container.Register<IRedisClientsManager>(new BasicRedisClientManager("localhost:6379"));
//Register Redis factory in Funq IoC. The default port for Redis is 6379.
container.Register<IRedisClientsManager>(new BasicRedisClientManager("localhost:6379"));

//Register user-defined REST Paths
Routes
.Add<Todo>("/todos")
.Add<Todo>("/todos/{Id}");
}
}
//Register user-defined REST Paths
Routes
.Add<Todo>("/todos")
.Add<Todo>("/todos/{Id}");
}
}

public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
new AppHost().Init(); //Start ServiceStack App
}
}
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
//Initialize your application
(new ToDoAppHost()).Init();
}
}
}
File renamed without changes.
Loading