@@ -17,26 +17,17 @@ namespace Quantumart.QP8.BLL.Services
17
17
{
18
18
public class SiteService
19
19
{
20
- public static SiteInitListResult InitList ( int parentId )
20
+ public static SiteInitListResult InitList ( int parentId ) => new SiteInitListResult
21
21
{
22
- return new SiteInitListResult
23
- {
24
- IsAddNewAccessable = SecurityRepository . IsActionAccessible ( ActionCode . AddNewSite )
25
- } ;
26
- }
22
+ IsAddNewAccessable = SecurityRepository . IsActionAccessible ( ActionCode . AddNewSite )
23
+ } ;
27
24
28
- public static SiteInitListResult MultipleInitList ( int parentId )
25
+ public static SiteInitListResult MultipleInitList ( int parentId ) => new SiteInitListResult
29
26
{
30
- return new SiteInitListResult
31
- {
32
- IsAddNewAccessable = false
33
- } ;
34
- }
27
+ IsAddNewAccessable = false
28
+ } ;
35
29
36
- public static ListResult < SiteListItem > List ( ListCommand cmd , IEnumerable < int > selectedIDs = null )
37
- {
38
- return SiteRepository . GetList ( cmd , selectedIDs ) ;
39
- }
30
+ public static ListResult < SiteListItem > List ( ListCommand cmd , IEnumerable < int > selectedIDs = null ) => SiteRepository . GetList ( cmd , selectedIDs ) ;
40
31
41
32
public static IEnumerable < ListItem > GetAllSites ( )
42
33
{
@@ -45,19 +36,13 @@ public static IEnumerable<ListItem> GetAllSites()
45
36
46
37
public static IEnumerable < ListItem > GetSites ( )
47
38
{
48
- var cmd = new ListCommand ( ) { PageSize = int . MaxValue , StartPage = 1 } ;
39
+ var cmd = new ListCommand { PageSize = int . MaxValue , StartPage = 1 } ;
49
40
return SiteRepository . GetList ( cmd , null ) . Data . Select ( s => new ListItem ( s . Id . ToString ( ) , s . Name ) ) . ToArray ( ) ;
50
41
}
51
42
52
- public static Site Read ( int id )
53
- {
54
- return Read ( id , true ) ;
55
- }
43
+ public static Site Read ( int id ) => Read ( id , true ) ;
56
44
57
- public static Site ReadForUpdate ( int id )
58
- {
59
- return Read ( id , false ) ;
60
- }
45
+ public static Site ReadForUpdate ( int id ) => Read ( id , false ) ;
61
46
62
47
public static Site Save ( Site item , int [ ] activeCommands , int [ ] activeStyles )
63
48
{
@@ -139,24 +124,38 @@ public static MessageResult AssembleContents(int id)
139
124
var stageTempDirectory = $@ "{ site . TempDirectoryForClasses } \stage";
140
125
141
126
if ( Directory . Exists ( liveTempDirectory ) )
127
+ {
142
128
Directory . Delete ( liveTempDirectory , true ) ;
143
- Directory . CreateDirectory ( liveTempDirectory ) ;
129
+ }
144
130
131
+ Directory . CreateDirectory ( liveTempDirectory ) ;
145
132
if ( Directory . Exists ( stageTempDirectory ) )
133
+ {
146
134
Directory . Delete ( stageTempDirectory , true ) ;
147
- Directory . CreateDirectory ( stageTempDirectory ) ;
135
+ }
148
136
137
+ Directory . CreateDirectory ( stageTempDirectory ) ;
149
138
if ( File . Exists ( site . TempArchiveForClasses ) )
139
+ {
150
140
File . Delete ( site . TempArchiveForClasses ) ;
151
-
152
-
153
- ( new AssembleContentsController ( id , sqlMetalPath , QPContext . CurrentDbConnectionString ) { SiteRoot = liveTempDirectory , IsLive = true , DisableClassGeneration = site . DownloadEfSource } ) . Assemble ( ) ;
154
- ( new AssembleContentsController ( id , sqlMetalPath , QPContext . CurrentDbConnectionString ) { SiteRoot = stageTempDirectory , IsLive = false , DisableClassGeneration = site . DownloadEfSource } ) . Assemble ( ) ;
141
+ }
142
+
143
+ new AssembleContentsController ( id , sqlMetalPath , QPContext . CurrentDbConnectionString )
144
+ {
145
+ SiteRoot = liveTempDirectory ,
146
+ IsLive = true ,
147
+ DisableClassGeneration = site . DownloadEfSource
148
+ } . Assemble ( ) ;
149
+
150
+ new AssembleContentsController ( id , sqlMetalPath , QPContext . CurrentDbConnectionString )
151
+ {
152
+ SiteRoot = stageTempDirectory ,
153
+ IsLive = false ,
154
+ DisableClassGeneration = site . DownloadEfSource
155
+ } . Assemble ( ) ;
155
156
156
157
ZipFile . CreateFromDirectory ( site . TempDirectoryForClasses , site . TempArchiveForClasses ) ;
157
-
158
158
return MessageResult . Download ( $ "/Backend/Site/GetClassesZip/{ id } ") ;
159
-
160
159
}
161
160
162
161
new AssembleContentsController ( id , sqlMetalPath , QPContext . CurrentDbConnectionString ) . Assemble ( ) ;
@@ -188,15 +187,9 @@ public static void CaptureLock(int id)
188
187
}
189
188
}
190
189
191
- public static Site New ( )
192
- {
193
- return new Site ( ) ;
194
- }
190
+ public static Site New ( ) => new Site ( ) ;
195
191
196
- public static Site NewForSave ( )
197
- {
198
- return new Site ( ) ;
199
- }
192
+ public static Site NewForSave ( ) => new Site ( ) ;
200
193
201
194
public static LibraryResult Library ( int id , string subFolder )
202
195
{
@@ -208,7 +201,7 @@ public static LibraryResult Library(int id, string subFolder)
208
201
var factory = new SiteFolderFactory ( ) ;
209
202
var repository = factory . CreateRepository ( ) ;
210
203
var folder = repository . GetBySubFolder ( id , subFolder ) ;
211
- return new LibraryResult ( ) { Folder = folder } ;
204
+ return new LibraryResult { Folder = folder } ;
212
205
}
213
206
214
207
public static ListResult < FolderFile > GetFileList ( ListCommand command , int parentFolderId , LibraryFileFilter filter )
@@ -224,35 +217,20 @@ public static ListResult<FolderFile> GetFileList(ListCommand command, int parent
224
217
return folder . GetFiles ( command , filter ) ;
225
218
}
226
219
227
- public static PathInfo GetPathInfo ( int folderId )
228
- {
229
- return SiteFolder . GetPathInfo ( folderId ) ;
230
- }
220
+ public static PathInfo GetPathInfo ( int folderId ) => SiteFolder . GetPathInfo ( folderId ) ;
231
221
232
- internal static IEnumerable < ListItem > GetSites ( IEnumerable < int > siteIDs )
233
- {
234
- return SiteRepository . GetSimpleList ( siteIDs ) ;
235
- }
222
+ internal static IEnumerable < ListItem > GetSites ( IEnumerable < int > siteIDs ) => SiteRepository . GetSimpleList ( siteIDs ) ;
236
223
237
- public static IEnumerable < VisualEditorCommand > GetAllVisualEditorCommands ( )
238
- {
239
- return VisualEditorRepository . GetDefaultCommands ( ) ;
240
- }
224
+ public static IEnumerable < VisualEditorCommand > GetAllVisualEditorCommands ( ) => VisualEditorRepository . GetDefaultCommands ( ) ;
241
225
242
226
public static IEnumerable < VisualEditorStyle > GetAllVeStyles ( )
243
227
{
244
228
return VisualEditorRepository . GetAllStyles ( ) . OrderBy ( s => s . Order ) . ToList ( ) ;
245
229
}
246
230
247
- public static Dictionary < int , bool > GetCommandBinding ( int siteId )
248
- {
249
- return VisualEditorRepository . GetCommandBindingBySiteId ( siteId ) ;
250
- }
231
+ public static Dictionary < int , bool > GetCommandBinding ( int siteId ) => VisualEditorRepository . GetCommandBindingBySiteId ( siteId ) ;
251
232
252
- public static Dictionary < int , bool > GetStyleBinding ( int siteId )
253
- {
254
- return VisualEditorRepository . GetStyleBindingBySiteId ( siteId ) ;
255
- }
233
+ public static Dictionary < int , bool > GetStyleBinding ( int siteId ) => VisualEditorRepository . GetStyleBindingBySiteId ( siteId ) ;
256
234
257
235
internal static void CopySiteSettings ( int sourceSiteId , int destinationSiteId )
258
236
{
0 commit comments