Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Project
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
apis
Project
Merge requests
!6
Topic/181 resource handling
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Topic/181 resource handling
Topic/181-resourceHandling
into
Product/168-BasicStructure
Overview
0
Commits
3
Pipelines
1
Changes
3
Merged
David Schimmel
requested to merge
Topic/181-resourceHandling
into
Product/168-BasicStructure
5 years ago
Overview
0
Commits
3
Pipelines
1
Changes
3
Expand
coscine/issues#168
0
0
Merge request reports
Compare
Product/168-BasicStructure
Product/168-BasicStructure (base)
and
latest version
latest version
4db68b64
3 commits,
5 years ago
3 files
+
68
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/Project/Controllers/ProjectController.cs
+
32
−
0
Options
@@ -6,6 +6,7 @@ using Coscine.Api.Project.ReturnObjects;
using
Coscine.ApiCommons
;
using
Coscine.ApiCommons.Exceptions
;
using
Coscine.ApiCommons.Factories
;
using
Coscine.Database.Model
;
using
Microsoft.AspNetCore.Mvc
;
using
System
;
using
System.Collections.Generic
;
@@ -61,6 +62,37 @@ namespace Coscine.Api.Project.Controllers
}));
}
[
HttpGet
(
"[controller]/{id}/resources"
)]
public
IActionResult
GetResources
(
string
id
)
{
return
Ok
(
_authenticator
.
ValidateAndExecute
((
user
)
=>
{
var
project
=
_projectModel
.
GetById
(
Guid
.
Parse
(
id
));
ResourceModel
resourceModel
=
new
ResourceModel
();
ResourceTypeModel
resourceTypeModel
=
new
ResourceTypeModel
();
if
(
_projectModel
.
CanSeeProject
(
user
,
project
))
{
return
resourceModel
.
GetAllWhere
((
resource
)
=>
(
from
projectResource
in
resource
.
ProjectResourceResourceIdIds
where
projectResource
.
ProjectId
==
project
.
Id
select
projectResource
).
Any
())
.
Select
((
resource
)
=>
{
ResourceType
resourceType
=
resource
.
Type
;
if
(
resourceType
==
null
)
{
resourceType
=
resourceTypeModel
.
GetById
(
resource
.
TypeId
);
}
return
new
ResourceObject
(
resource
.
Id
,
resource
.
ExternalId
,
resource
.
Url
,
new
ResourceTypeObject
(
resourceType
.
Id
,
resourceType
.
DisplayName
));
});
}
else
{
throw
new
UnauthorizedAccessException
(
"User cannot see resources of given project!"
);
}
}));
}
[
HttpPost
(
"[controller]/{id}"
)]
public
IActionResult
Update
(
string
id
)
{
Loading