Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 7591d2f

Browse files
Step 2 done for Quatro
1 parent 8a33bdc commit 7591d2f

File tree

3 files changed

+196
-3
lines changed

3 files changed

+196
-3
lines changed

src/3-Nancy-FSharp/Entities.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ type Post = {
171171
Text : string
172172
CategoryIds : string list
173173
Tags : string list
174-
PriorPermalinks : string list
175174
Revisions : Revision list
176175
}
177176
with
@@ -187,6 +186,5 @@ with
187186
Text = ""
188187
CategoryIds = []
189188
Tags = []
190-
PriorPermalinks = []
191189
Revisions = []
192190
}

src/4-Freya-FSharp/Entities.fs

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
namespace Quatro.Entities
2+
3+
open Newtonsoft.Json
4+
5+
type CategoryId = CategoryId of string
6+
type CommentId = CommentId of string
7+
type PageId = PageId of string
8+
type PostId = PostId of string
9+
type UserId = UserId of string
10+
type WebLogId = WebLogId of string
11+
12+
type Permalink = Permalink of string
13+
type Tag = Tag of string
14+
type Ticks = Ticks of int64
15+
type TimeZone = TimeZone of string
16+
type Url = Url of string
17+
18+
type AuthorizationLevel =
19+
| Administrator
20+
| User
21+
22+
type PostStatus =
23+
| Draft
24+
| Published
25+
26+
type CommentStatus =
27+
| Approved
28+
| Pending
29+
| Spam
30+
31+
type Revision = {
32+
AsOf : Ticks
33+
Text : string
34+
}
35+
with
36+
static member Empty =
37+
{ AsOf = Ticks 0L
38+
Text = ""
39+
}
40+
41+
type Page = {
42+
[<JsonProperty("id")>]
43+
Id : PageId
44+
WebLogId : WebLogId
45+
AuthorId : UserId
46+
Title : string
47+
Permalink : Permalink
48+
PublishedOn : Ticks
49+
UpdatedOn : Ticks
50+
ShowInPageList : bool
51+
Text : string
52+
Revisions : Revision list
53+
}
54+
with
55+
static member Empty =
56+
{ Id = PageId ""
57+
WebLogId = WebLogId ""
58+
AuthorId = UserId ""
59+
Title = ""
60+
Permalink = Permalink ""
61+
PublishedOn = Ticks 0L
62+
UpdatedOn = Ticks 0L
63+
ShowInPageList = false
64+
Text = ""
65+
Revisions = []
66+
}
67+
68+
type WebLog = {
69+
[<JsonProperty("id")>]
70+
Id : WebLogId
71+
Name : string
72+
Subtitle : string option
73+
DefaultPage : string
74+
ThemePath : string
75+
UrlBase : string
76+
TimeZone : TimeZone
77+
}
78+
with
79+
/// An empty web log
80+
static member Empty =
81+
{ Id = WebLogId ""
82+
Name = ""
83+
Subtitle = None
84+
DefaultPage = ""
85+
ThemePath = "default"
86+
UrlBase = ""
87+
TimeZone = TimeZone "America/New_York"
88+
}
89+
90+
type Authorization = {
91+
WebLogId : WebLogId
92+
Level : AuthorizationLevel
93+
}
94+
95+
type User = {
96+
[<JsonProperty("id")>]
97+
Id : UserId
98+
EmailAddress : string
99+
PasswordHash : string
100+
FirstName : string
101+
LastName : string
102+
PreferredName : string
103+
Url : Url option
104+
Authorizations : Authorization list
105+
}
106+
with
107+
static member Empty =
108+
{ Id = UserId ""
109+
EmailAddress = ""
110+
FirstName = ""
111+
LastName = ""
112+
PreferredName = ""
113+
PasswordHash = ""
114+
Url = None
115+
Authorizations = []
116+
}
117+
118+
type Category = {
119+
[<JsonProperty("id")>]
120+
Id : CategoryId
121+
WebLogId : WebLogId
122+
Name : string
123+
Slug : string
124+
Description : string option
125+
ParentId : CategoryId option
126+
Children : CategoryId list
127+
}
128+
with
129+
static member Empty =
130+
{ Id = CategoryId "new"
131+
WebLogId = WebLogId ""
132+
Name = ""
133+
Slug = ""
134+
Description = None
135+
ParentId = None
136+
Children = []
137+
}
138+
139+
type Comment = {
140+
[<JsonProperty("id")>]
141+
Id : CommentId
142+
PostId : PostId
143+
InReplyToId : CommentId option
144+
Name : string
145+
EmailAddress : string
146+
Url : Url option
147+
Status : CommentStatus
148+
PostedOn : Ticks
149+
Text : string
150+
}
151+
with
152+
static member Empty =
153+
{ Id = CommentId ""
154+
PostId = PostId ""
155+
InReplyToId = None
156+
Name = ""
157+
EmailAddress = ""
158+
Url = None
159+
Status = Pending
160+
PostedOn = Ticks 0L
161+
Text = ""
162+
}
163+
164+
type Post = {
165+
[<JsonProperty("id")>]
166+
Id : PostId
167+
WebLogId : WebLogId
168+
AuthorId : UserId
169+
Status : PostStatus
170+
Title : string
171+
Permalink : string
172+
PublishedOn : Ticks
173+
UpdatedOn : Ticks
174+
Text : string
175+
CategoryIds : CategoryId list
176+
Tags : Tag list
177+
Revisions : Revision list
178+
}
179+
with
180+
static member Empty =
181+
{ Id = PostId "new"
182+
WebLogId = WebLogId ""
183+
AuthorId = UserId ""
184+
Status = Draft
185+
Title = ""
186+
Permalink = ""
187+
PublishedOn = Ticks 0L
188+
UpdatedOn = Ticks 0L
189+
Text = ""
190+
CategoryIds = []
191+
Tags = []
192+
Revisions = []
193+
}

src/4-Freya-FSharp/project.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"compilerName": "fsc",
66
"compile": {
77
"includeFiles": [
8+
"Entities.fs",
89
"App.fs"
910
]
1011
}
@@ -13,7 +14,8 @@
1314
"Freya": "3.0.0-rc01",
1415
"Microsoft.AspNetCore.Owin": "1.0.0",
1516
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
16-
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
17+
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
18+
"Newtonsoft.Json": "9.0.1"
1719
},
1820
"frameworks": {
1921
"netcoreapp1.0": {

0 commit comments

Comments
 (0)