Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lesson49
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Пасько Виталий
Lesson49
Commits
23bbaff5
Commit
23bbaff5
authored
Aug 08, 2022
by
Пасько Виталий
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Рефакторинг.
parent
328ca1aa
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
5 deletions
+6
-5
FeedbackController.cs
PhoneStore/Controllers/FeedbackController.cs
+1
-2
FeedbackService.cs
PhoneStore/Services/FeedbackService.cs
+3
-2
IFeedbackService.cs
PhoneStore/Services/Interfaces/IFeedbackService.cs
+2
-1
No files found.
PhoneStore/Controllers/FeedbackController.cs
View file @
23bbaff5
...
...
@@ -23,8 +23,7 @@ namespace PhoneStore.Controllers
public
ActionResult
<
FeedbackViewModel
>
Create
(
FeedbackCreateViewModel
model
)
{
//TODO: валидация.
var
userId
=
int
.
Parse
(
_userManager
.
GetUserId
(
User
));
var
feedbackViewModel
=
_feedbackService
.
Create
(
model
,
userId
);
var
feedbackViewModel
=
_feedbackService
.
Create
(
model
,
User
);
return
Json
(
feedbackViewModel
);
}
...
...
PhoneStore/Services/FeedbackService.cs
View file @
23bbaff5
using
System
;
using
System.Linq
;
using
System.Security.Claims
;
using
Microsoft.AspNetCore.Identity
;
using
Microsoft.EntityFrameworkCore
;
using
PhoneStore.Helpers
;
...
...
@@ -22,14 +23,14 @@ namespace PhoneStore.Services
_userManager
=
userManager
;
}
public
FeedbackViewModel
Create
(
FeedbackCreateViewModel
model
,
int
userId
)
public
FeedbackViewModel
Create
(
FeedbackCreateViewModel
model
,
ClaimsPrincipal
user
)
{
Feedback
feedback
=
new
Feedback
{
CreationDateTime
=
DateTime
.
Now
,
Text
=
model
.
Text
,
PhoneId
=
model
.
PhoneId
,
UserId
=
userId
UserId
=
int
.
Parse
(
_userManager
.
GetUserId
(
user
))
};
_db
.
Feedbacks
.
Add
(
feedback
);
_db
.
SaveChanges
();
...
...
PhoneStore/Services/Interfaces/IFeedbackService.cs
View file @
23bbaff5
using
System.Security.Claims
;
using
PhoneStore.ViewModels.Feedback
;
namespace
PhoneStore.Services.Interfaces
{
public
interface
IFeedbackService
{
FeedbackViewModel
Create
(
FeedbackCreateViewModel
model
,
int
userId
);
FeedbackViewModel
Create
(
FeedbackCreateViewModel
model
,
ClaimsPrincipal
user
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment