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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rodrigo Sastre Marotta
tsi1-backend
Merge requests
!32
Feature/activities
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Feature/activities
feature/activities
into
develop
Overview
0
Commits
3
Pipelines
0
Changes
26
Merged
Enzo Santangelo Dodera
requested to merge
feature/activities
into
develop
4 years ago
Overview
0
Commits
3
Pipelines
0
Changes
26
Expand
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
a87c53fd
3 commits,
4 years ago
26 files
+
1700
−
13
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
26
Search (e.g. *.vue) (Ctrl+P)
Tsi1.Api/Tsi1.Api/Controllers/ActivityController.cs
0 → 100644
+
84
−
0
Options
using
Microsoft.AspNetCore.Authorization
;
using
Microsoft.AspNetCore.Http
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Tsi1.BusinessLayer.Dtos
;
using
Tsi1.BusinessLayer.Helpers
;
using
Tsi1.BusinessLayer.Interfaces
;
namespace
Tsi1.Api.Controllers
{
[
Route
(
"api/[controller]"
)]
[
ApiController
]
public
class
ActivityController
:
ControllerBase
{
private
readonly
IActivityService
_activityService
;
public
ActivityController
(
IActivityService
activityService
)
{
_activityService
=
activityService
;
}
[
Authorize
(
Roles
=
UserTypes
.
FacultyAdmin
+
", "
+
UserTypes
.
Professor
+
", "
+
UserTypes
.
Student
)]
[
HttpGet
(
"GetAll/{courseId}"
)]
public
async
Task
<
IActionResult
>
GetAll
(
int
courseId
)
{
var
result
=
await
_activityService
.
GetAll
(
courseId
);
if
(
result
.
HasError
)
{
return
BadRequest
(
result
.
Message
);
}
return
Ok
(
result
.
Data
);
}
[
Authorize
(
Roles
=
UserTypes
.
FacultyAdmin
+
", "
+
UserTypes
.
Professor
)]
[
HttpPost
(
"Create"
)]
public
async
Task
<
IActionResult
>
Create
(
ActivityCreateDto
newActivity
)
{
var
userId
=
int
.
Parse
(
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
"Id"
).
Value
);
var
result
=
await
_activityService
.
Create
(
newActivity
,
userId
);
if
(
result
.
HasError
)
{
return
BadRequest
(
result
.
Message
);
}
return
Ok
(
result
.
Data
);
}
[
Authorize
(
Roles
=
UserTypes
.
FacultyAdmin
+
", "
+
UserTypes
.
Professor
)]
[
HttpPut
(
"Modify/{activityId}"
)]
public
async
Task
<
IActionResult
>
Modify
(
int
activityId
,
ActivityModifyDto
activityDto
)
{
var
userId
=
int
.
Parse
(
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
"Id"
).
Value
);
var
result
=
await
_activityService
.
Modify
(
activityId
,
activityDto
,
userId
);
if
(
result
.
HasError
)
{
return
BadRequest
(
result
.
Message
);
}
return
Ok
();
}
[
Authorize
(
Roles
=
UserTypes
.
FacultyAdmin
+
", "
+
UserTypes
.
Professor
)]
[
HttpDelete
(
"Delete/{activityId}"
)]
public
async
Task
<
IActionResult
>
Delete
(
int
activityId
)
{
var
userId
=
int
.
Parse
(
HttpContext
.
User
.
Claims
.
FirstOrDefault
(
x
=>
x
.
Type
==
"Id"
).
Value
);
var
result
=
await
_activityService
.
Delete
(
activityId
,
userId
);
if
(
result
.
HasError
)
{
return
BadRequest
(
result
.
Message
);
}
return
Ok
();
}
}
}
Loading