forked from wojilu/wojilu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainController.cs
executable file
·111 lines (80 loc) · 3.31 KB
/
MainController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright (c) 2010, www.wojilu.com. All rights reserved.
*/
using System;
using System.Collections.Generic;
using wojilu.Web.Mvc;
using wojilu.Web.Mvc.Attr;
using wojilu.Web.Controller.Security;
using wojilu.Common.AppBase;
using wojilu.Members.Interface;
using wojilu.Members.Sites.Domain;
using wojilu.Members.Sites.Service;
using wojilu.Apps.Photo.Domain;
using wojilu.Apps.Photo.Interface;
using wojilu.Apps.Photo.Service;
namespace wojilu.Web.Controller.Admin.Apps.Photo {
[App( typeof( PhotoApp ) )]
public partial class MainController : ControllerBase {
public virtual ISysPhotoService photoService { get; set; }
public virtual IPhotoPostService postService { get; set; }
public virtual IPickedService pickedService { get; set; }
public virtual IPhotoSysCategoryService categoryService { get; set; }
public virtual IAdminLogService<SiteLog> logService { get; set; }
public MainController() {
photoService = new SysPhotoService();
postService = new PhotoPostService();
pickedService = new PickedService();
categoryService = new PhotoSysCategoryService();
logService = new SiteLogService();
}
public static readonly int pageSize = 40;
public override void Layout() {
List<PhotoSysCategory> categories = categoryService.GetAll();
bindList( "categories", "c", categories, bindCatLink );
}
private void bindCatLink( IBlock tpl, long id ) {
tpl.Set( "c.LinkCategory", to( new MainController().Index, id ) );
}
public virtual void Index( long id ) {
DataPage<PhotoPost> list = photoService.GetSysPostPage( id, pageSize );
bindList( "list", "photo", list.Results, bindLink );
set( "page", list.PageBar );
setCategoryDropList();
target( Admin );
}
[HttpPost, DbTransaction]
public virtual void Admin() {
String ids = ctx.Post( "choice" );
String cmd = ctx.Post( "action" );
long categoryId = ctx.PostLong( "categoryId" );
if (strUtil.IsNullOrEmpty( cmd ) || cvt.IsIdListValid( ids ) == false) {
content( lang( "exCmd" ) );
return;
}
String condition = string.Format( "Id in ({0}) ", ids );
if ("pick".Equals( cmd )) {
pickedService.PickPost( ids );
log( SiteLogString.PickPhotoPost(), ids );
echoAjaxOk();
}
else if ("delete".Equals( cmd )) {
PhotoPost.updateBatch( "set SaveStatus=" + SaveStatus.SysDelete, condition );
log( SiteLogString.DeleteSysPhotoPost(), ids );
echoAjaxOk();
}
else if ("category".Equals( cmd )) {
if (categoryId < 0) {
content( lang( "exCategoryNotFound" ) );
return;
}
if (categoryId == zeroCatId) categoryId = 0;
PhotoPost.updateBatch( "set SysCategoryId=" + categoryId, condition );
log( SiteLogString.MovePhotoPost(), ids );
echoAjaxOk();
}
else
content( lang( "exCmd" ) );
}
}
}