Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsi1-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rodrigo Sastre Marotta
tsi1-backend
Merge requests
!27
fix GetMyCommunications and add 2 endpoints
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
fix GetMyCommunications and add 2 endpoints
feature/fix-communications
into
develop
Overview
0
Commits
1
Pipelines
0
Changes
3
Merged
fix GetMyCommunications and add 2 endpoints
Enzo Santangelo Dodera
requested to merge
feature/fix-communications
into
develop
Nov 21, 2020
Overview
0
Commits
1
Pipelines
0
Changes
3
0
0
Merge request reports
Viewing commit
67f8566c
Show latest version
3 files
+
100
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
67f8566c
fix GetMyCommunications and add 2 endpoints
· 67f8566c
esantangelo
authored
Nov 21, 2020
Tsi1.Api/Tsi1.Api/Controllers/CommunicationController.cs
+
38
−
1
View file @ 67f8566c
Edit in single-file editor
Open in Web IDE
Show full file
@@ -71,8 +71,45 @@ namespace Tsi1.Api.Controllers
public
async
Task
<
IActionResult
>
GetMyCommunications
()
{
var
userId
=
int
.
Parse
(
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
"Id"
).
Value
);
var
tenantId
=
int
.
Parse
(
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
"TenantId"
).
Value
);
var
result
=
await
_communicationService
.
GetMyCommunications
(
userId
,
tenantId
);
if
(
result
.
HasError
)
{
return
BadRequest
(
result
.
Message
);
}
return
Ok
(
result
.
Data
);
}
[
Authorize
(
Roles
=
UserTypes
.
Student
+
", "
+
UserTypes
.
FacultyAdmin
+
", "
+
UserTypes
.
Professor
)]
[
HttpGet
(
"GetCourseCommunications/{courseId}"
)]
public
async
Task
<
IActionResult
>
GetCourseCommunications
(
int
courseId
)
{
var
tenantId
=
int
.
Parse
(
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
"TenantId"
).
Value
);
var
result
=
await
_communicationService
.
GetCourseCommunications
(
courseId
,
tenantId
);
if
(
result
.
HasError
)
{
return
BadRequest
(
result
.
Message
);
}
return
Ok
(
result
.
Data
);
}
[
Authorize
(
Roles
=
UserTypes
.
Student
+
", "
+
UserTypes
.
FacultyAdmin
+
", "
+
UserTypes
.
Professor
+
", "
+
UserTypes
.
UdelarAdmin
)]
[
HttpGet
(
"GetGlobalCommunications"
)]
public
async
Task
<
IActionResult
>
GetGlobalCommunications
(
int
tenantId
)
{
var
userType
=
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
ClaimTypes
.
Role
).
Value
;
if
(
userType
!=
UserTypes
.
UdelarAdmin
)
{
tenantId
=
int
.
Parse
(
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
"TenantId"
).
Value
);
}
var
result
=
await
_communicationService
.
Get
My
Communications
(
user
Id
);
var
result
=
await
_communicationService
.
Get
Global
Communications
(
tenant
Id
);
if
(
result
.
HasError
)
{
Loading