FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Blog.Core/Blog.Core/Controllers/TransactionController.cs at master · githubsunyf/Blog.Core · GitHub
githubsunyf
Blog.Core
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Blog.Core
/
Blog.Core
/
Controllers
/
TransactionController.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
119 lines (98 loc) · 3.88 KB
Breadcrumbs
Blog.Core
/
Blog.Core
/
Controllers
/
TransactionController.cs
Copy path
File metadata and controls
119 lines (98 loc) · 3.88 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
112
113
114
115
116
117
118
119
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Threading
.
Tasks
;
using
Blog
.
Core
.
IRepository
.
UnitOfWork
;
using
Blog
.
Core
.
IServices
;
using
Blog
.
Core
.
Model
.
Models
;
using
Microsoft
.
AspNetCore
.
Authorization
;
using
Microsoft
.
AspNetCore
.
Mvc
;
namespace
Blog
.
Core
.
Controllers
{
[
Route
(
"api/[controller]/[action]"
)
]
[
ApiController
]
[
AllowAnonymous
]
public
class
TransactionController
:
ControllerBase
{
private
readonly
IPasswordLibServices
_passwordLibServices
;
private
readonly
IGuestbookServices
_guestbookServices
;
private
readonly
IUnitOfWork
_unitOfWork
;
public
TransactionController
(
IUnitOfWork
unitOfWork
,
IPasswordLibServices
passwordLibServices
,
IGuestbookServices
guestbookServices
)
{
_unitOfWork
=
unitOfWork
;
_passwordLibServices
=
passwordLibServices
;
_guestbookServices
=
guestbookServices
;
}
// GET: api/Transaction
[
HttpGet
]
public
async
Task
<
IEnumerable
<
string
>
>
Get
(
)
{
List
<
string
>
returnMsg
=
new
List
<
string
>
(
)
{
}
;
try
{
returnMsg
.
Add
(
$
"Begin Transaction"
)
;
_unitOfWork
.
BeginTran
(
)
;
var
passwords
=
await
_passwordLibServices
.
Query
(
d
=>
d
.
IsDeleted
==
false
)
;
returnMsg
.
Add
(
$
"first time : the count of passwords is :
{
passwords
.
Count
}
"
)
;
returnMsg
.
Add
(
$
"insert a data into the table PasswordLib now."
)
;
var
insertPassword
=
await
_passwordLibServices
.
Add
(
new
PasswordLib
(
)
{
IsDeleted
=
false
,
plAccountName
=
"aaa"
,
plCreateTime
=
DateTime
.
Now
}
)
;
passwords
=
await
_passwordLibServices
.
Query
(
d
=>
d
.
IsDeleted
==
false
)
;
returnMsg
.
Add
(
$
"second time : the count of passwords is :
{
passwords
.
Count
}
"
)
;
returnMsg
.
Add
(
$
" "
)
;
//......
var
guestbooks
=
await
_guestbookServices
.
Query
(
)
;
returnMsg
.
Add
(
$
"first time : the count of guestbooks is :
{
guestbooks
.
Count
}
"
)
;
int
ex
=
0
;
returnMsg
.
Add
(
$
"There's an exception!!"
)
;
returnMsg
.
Add
(
$
" "
)
;
int
throwEx
=
1
/
ex
;
var
insertGuestbook
=
await
_guestbookServices
.
Add
(
new
Guestbook
(
)
{
username
=
"bbb"
,
blogId
=
1
,
createdate
=
DateTime
.
Now
,
isshow
=
true
}
)
;
guestbooks
=
await
_guestbookServices
.
Query
(
)
;
returnMsg
.
Add
(
$
"first time : the count of guestbooks is :
{
guestbooks
.
Count
}
"
)
;
returnMsg
.
Add
(
$
" "
)
;
_unitOfWork
.
CommitTran
(
)
;
}
catch
(
Exception
)
{
_unitOfWork
.
RollbackTran
(
)
;
var
passwords
=
await
_passwordLibServices
.
Query
(
)
;
returnMsg
.
Add
(
$
"third time : the count of passwords is :
{
passwords
.
Count
}
"
)
;
var
guestbooks
=
await
_guestbookServices
.
Query
(
)
;
returnMsg
.
Add
(
$
"third time : the count of guestbooks is :
{
guestbooks
.
Count
}
"
)
;
}
return
returnMsg
;
}
// GET: api/Transaction/5
[
HttpGet
(
"{id}"
)
]
public
async
Task
<
bool
>
Get
(
int
id
)
{
return
await
_guestbookServices
.
TestTranInRepository
(
)
;
}
// POST: api/Transaction
[
HttpPost
]
public
void
Post
(
[
FromBody
]
string
value
)
{
}
// PUT: api/Transaction/5
[
HttpPut
(
"{id}"
)
]
public
void
Put
(
int
id
,
[
FromBody
]
string
value
)
{
}
// DELETE: api/ApiWithActions/5
[
HttpDelete
(
"{id}"
)
]
public
async
Task
<
bool
>
Delete
(
int
id
)
{
return
await
_guestbookServices
.
TestTranInRepositoryAOP
(
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL