Skip to content

Commit 02e2529

Browse files
committed
Update RedisStackOverflow to New API
1 parent 26176c8 commit 02e2529

File tree

20 files changed

+485
-436
lines changed

20 files changed

+485
-436
lines changed
Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,32 @@
1-
using System;
2-
using System.Runtime.Serialization;
3-
using ServiceStack.ServiceHost;
1+
using RedisStackOverflow.ServiceModel;
42
using ServiceStack.ServiceInterface;
5-
using ServiceStack.ServiceInterface.ServiceModel;
63

74
namespace RedisStackOverflow.ServiceInterface
85
{
9-
/// <summary>
10-
/// Define your ServiceStack web service request (i.e. the Request DTO).
11-
/// </summary>
12-
[Route("/answers")]
13-
public class Answers
14-
{
15-
public int UserId { get; set; }
16-
public int AnswerId { get; set; }
17-
public int QuestionId { get; set; }
18-
public string Content { get; set; }
19-
}
20-
21-
/// <summary>
22-
/// Define your ServiceStack web service response (i.e. Response DTO).
23-
/// </summary>
24-
public class AnswersResponse : IHasResponseStatus
25-
{
26-
/// <summary>
27-
/// Gets or sets the ResponseStatus. The built-in Ioc used with ServiceStack autowires this property with service exceptions.
28-
/// </summary>
29-
public ResponseStatus ResponseStatus { get; set; }
30-
}
316

327
/// <summary>
338
/// Create your ServiceStack rest-ful web service implementation.
349
/// </summary>
35-
public class AnswersService : RestServiceBase<Answers>
10+
public class AnswersService : Service
3611
{
3712
/// <summary>
3813
/// Gets or sets the repository. The built-in IoC used with ServiceStack autowires this property.
3914
/// </summary>
4015
public IRepository Repository { get; set; }
4116

42-
public override object OnPost(Answers request)
17+
public void Post(Answers request)
4318
{
4419
Repository.StoreAnswer(new Answer
4520
{
4621
UserId = request.UserId,
4722
QuestionId = request.QuestionId,
4823
Content = request.Content
4924
});
50-
return new AnswersResponse();
5125
}
5226

53-
public override object OnDelete(Answers request)
27+
public void Delete(Answers request)
5428
{
5529
Repository.DeleteAnswer(request.QuestionId, request.AnswerId);
56-
return new AnswersResponse();
5730
}
5831
}
5932
}

src/RedisStackOverflow/RedisStackOverflow.ServiceInterface/IRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using RedisStackOverflow.ServiceModel;
45
using ServiceStack.Common.Utils;
56
using ServiceStack.Redis;
67
using ServiceStack.Common.Extensions;

src/RedisStackOverflow/RedisStackOverflow.ServiceInterface/QuestionService.cs

Lines changed: 0 additions & 89 deletions
This file was deleted.

src/RedisStackOverflow/RedisStackOverflow.ServiceInterface/QuestionStatService.cs

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 28 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,20 @@
1-
using System.Collections.Generic;
2-
using System.Runtime.Serialization;
1+
using RedisStackOverflow.ServiceModel;
32
using ServiceStack.Common.Extensions;
4-
using ServiceStack.ServiceHost;
53
using ServiceStack.ServiceInterface;
6-
using ServiceStack.ServiceInterface.ServiceModel;
74

85
namespace RedisStackOverflow.ServiceInterface
96
{
10-
/// <summary>
11-
/// Define your ServiceStack web service request (i.e. the Request DTO).
12-
/// </summary>
13-
[Route("/questions", "GET")]
14-
[Route("/questions/page/{Page}")]
15-
[Route("/questions/tagged/{Tag}")]
16-
[Route("/users/{UserId}/questions")]
17-
public class Questions
18-
{
19-
public int? Page { get; set; }
20-
public string Tag { get; set; }
21-
public long? UserId { get; set; }
22-
}
23-
24-
/// <summary>
25-
/// Define your ServiceStack web service response (i.e. Response DTO).
26-
/// </summary>
27-
public class QuestionsResponse
28-
{
29-
public QuestionsResponse()
30-
{
31-
//Comment this out if you wish to receive the response status.
32-
this.ResponseStatus = new ResponseStatus();
33-
}
34-
35-
public List<QuestionResult> Results { get; set; }
36-
37-
/// <summary>
38-
/// Gets or sets the ResponseStatus. The built-in Ioc used with ServiceStack autowires this property with service exceptions.
39-
/// </summary>
40-
public ResponseStatus ResponseStatus { get; set; }
41-
}
42-
43-
public class QuestionResult
44-
{
45-
public QuestionResult()
46-
{
47-
this.Answers = new List<AnswerResult>();
48-
}
49-
50-
public Question Question { get; set; }
51-
public User User { get; set; }
52-
public int AnswersCount { get; set; }
53-
public int VotesUpCount { get; set; }
54-
public int VotesDownCount { get; set; }
55-
public List<AnswerResult> Answers { get; set; }
56-
}
57-
58-
/// <summary>
7+
/// <summary>
598
/// Create your ServiceStack rest-ful web service implementation.
609
/// </summary>
61-
public class QuestionsService : RestServiceBase<Questions>
10+
public class QuestionsService : Service
6211
{
6312
/// <summary>
6413
/// Gets or sets the repository. The built-in IoC used with ServiceStack autowires this property.
6514
/// </summary>
6615
public IRepository Repository { get; set; }
6716

68-
public override object OnGet(Questions request)
17+
public object Get(Questions request)
6918
{
7019
if (!request.Tag.IsNullOrEmpty())
7120
return new QuestionsResponse { Results = Repository.GetQuestionsTaggedWith(request.Tag) };
@@ -76,5 +25,29 @@ public override object OnGet(Questions request)
7625
var pageOffset = request.Page.GetValueOrDefault(0) * 10;
7726
return new QuestionsResponse { Results = Repository.GetRecentQuestionResults(pageOffset, pageOffset + 10) };
7827
}
28+
29+
public object Get(Question question)
30+
{
31+
return new QuestionResponse {
32+
Result = Repository.GetQuestion(question.Id),
33+
};
34+
}
35+
36+
public void Post(Question question)
37+
{
38+
Repository.StoreQuestion(question);
39+
}
40+
41+
public void Delete(Question request)
42+
{
43+
Repository.DeleteQuestion(request.Id);
44+
}
45+
46+
public object Post(QuestionStats request)
47+
{
48+
return new QuestionStatsResponse {
49+
Result = Repository.GetQuestionStats(request.QuestionId)
50+
};
51+
}
7952
}
8053
}

src/RedisStackOverflow/RedisStackOverflow.ServiceInterface/RedisStackOverflow.ServiceInterface.csproj

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,29 @@
5252
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
5353
</PropertyGroup>
5454
<ItemGroup>
55-
<Reference Include="ServiceStack, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
56-
<HintPath>..\..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.dll</HintPath>
55+
<Reference Include="ServiceStack">
56+
<HintPath>..\packages\ServiceStack.3.9.32\lib\net35\ServiceStack.dll</HintPath>
5757
</Reference>
58-
<Reference Include="ServiceStack.Common, Version=3.9.9.0, Culture=neutral, processorArchitecture=MSIL">
59-
<HintPath>..\..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Common.dll</HintPath>
58+
<Reference Include="ServiceStack.Common">
59+
<HintPath>..\packages\ServiceStack.Common.3.9.32\lib\net35\ServiceStack.Common.dll</HintPath>
6060
</Reference>
61-
<Reference Include="ServiceStack.Interfaces, Version=3.9.9.0, Culture=neutral, processorArchitecture=MSIL">
62-
<HintPath>..\..\packages\ServiceStack.Common.3.9.11\lib\net35\ServiceStack.Interfaces.dll</HintPath>
61+
<Reference Include="ServiceStack.Interfaces">
62+
<HintPath>..\packages\ServiceStack.Common.3.9.32\lib\net35\ServiceStack.Interfaces.dll</HintPath>
63+
</Reference>
64+
<Reference Include="ServiceStack.OrmLite">
65+
<HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.32\lib\ServiceStack.OrmLite.dll</HintPath>
6366
</Reference>
6467
<Reference Include="ServiceStack.OrmLite.SqlServer">
65-
<HintPath>..\..\packages\ServiceStack.OrmLite.SqlServer.3.9.9\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
68+
<HintPath>..\packages\ServiceStack.OrmLite.SqlServer.3.9.32\lib\ServiceStack.OrmLite.SqlServer.dll</HintPath>
6669
</Reference>
67-
<Reference Include="ServiceStack.Redis, Version=3.9.11.0, Culture=neutral, processorArchitecture=MSIL">
68-
<HintPath>..\..\packages\ServiceStack.Redis.3.9.11\lib\net35\ServiceStack.Redis.dll</HintPath>
70+
<Reference Include="ServiceStack.Redis">
71+
<HintPath>..\packages\ServiceStack.Redis.3.9.32\lib\net35\ServiceStack.Redis.dll</HintPath>
6972
</Reference>
70-
<Reference Include="ServiceStack.ServiceInterface, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
71-
<HintPath>..\..\packages\ServiceStack.3.9.11\lib\net35\ServiceStack.ServiceInterface.dll</HintPath>
73+
<Reference Include="ServiceStack.ServiceInterface">
74+
<HintPath>..\packages\ServiceStack.3.9.32\lib\net35\ServiceStack.ServiceInterface.dll</HintPath>
7275
</Reference>
7376
<Reference Include="ServiceStack.Text">
74-
<HintPath>..\..\packages\ServiceStack.Text.3.9.11\lib\net35\ServiceStack.Text.dll</HintPath>
77+
<HintPath>..\packages\ServiceStack.Text.3.9.32\lib\net35\ServiceStack.Text.dll</HintPath>
7578
</Reference>
7679
<Reference Include="System" />
7780
<Reference Include="System.Core">
@@ -92,15 +95,11 @@
9295
<ItemGroup>
9396
<Compile Include="AnswersService.cs" />
9497
<Compile Include="ResetService.cs" />
95-
<Compile Include="UserStatsService.cs" />
9698
<Compile Include="StatsService.cs" />
97-
<Compile Include="QuestionStatService.cs" />
9899
<Compile Include="IRepository.cs" />
99100
<Compile Include="Properties\AssemblyInfo.cs" />
100-
<Compile Include="QuestionService.cs" />
101101
<Compile Include="QuestionsService.cs" />
102102
<Compile Include="UserService.cs" />
103-
<Compile Include="UserVotesService.cs" />
104103
</ItemGroup>
105104
<ItemGroup>
106105
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
@@ -122,6 +121,12 @@
122121
<ItemGroup>
123122
<None Include="packages.config" />
124123
</ItemGroup>
124+
<ItemGroup>
125+
<ProjectReference Include="..\RedisStackOverflow.ServiceModel\RedisStackOverflow.ServiceModel.csproj">
126+
<Project>{BFAB0E32-43F3-4A0E-9409-FC57FCF4BF14}</Project>
127+
<Name>RedisStackOverflow.ServiceModel</Name>
128+
</ProjectReference>
129+
</ItemGroup>
125130
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
126131
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
127132
Other similar extension points exist, see Microsoft.Common.targets.

0 commit comments

Comments
 (0)