aboutsummaryrefslogtreecommitdiff
path: root/backend/api
diff options
context:
space:
mode:
Diffstat (limited to 'backend/api')
-rw-r--r--backend/api/api/Controllers/ModelController.cs18
-rw-r--r--backend/api/api/Services/IModelService.cs1
-rw-r--r--backend/api/api/Services/ModelService.cs4
3 files changed, 23 insertions, 0 deletions
diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs
index ce1759ca..fb30a7a2 100644
--- a/backend/api/api/Controllers/ModelController.cs
+++ b/backend/api/api/Controllers/ModelController.cs
@@ -109,6 +109,24 @@ namespace api.Controllers
return _modelService.GetMyModels(uploaderId);
}
+ // GET: api/<ModelController>/mymodels
+ [HttpGet("mymodelsbytype/{problemtype}")]
+ [Authorize(Roles = "User")]
+ public ActionResult<List<Model>> GetMyModelsByType(string problemType)
+ {
+ string uploaderId = getUserId();
+
+ if (uploaderId == null)
+ return BadRequest();
+
+ List<Model> modeli = _modelService.GetMyModelsByType(uploaderId, problemType);
+
+ if (modeli == null)
+ return NoContent();
+ else
+ return modeli;
+ }
+
// vraca svoj model prema nekom imenu
// GET api/<ModelController>/{name}
[HttpGet("{name}")]
diff --git a/backend/api/api/Services/IModelService.cs b/backend/api/api/Services/IModelService.cs
index bcb82e2d..00299979 100644
--- a/backend/api/api/Services/IModelService.cs
+++ b/backend/api/api/Services/IModelService.cs
@@ -8,6 +8,7 @@ namespace api.Services
Model GetOneModel(string userId, string name);
Model GetOneModel(string id);
List<Model> GetMyModels(string userId);
+ List<Model> GetMyModelsByType(string userId, string problemType);
List<Model> GetLatestModels(string userId);
//List<Model> GetPublicModels();
Model Create(Model model);
diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs
index d3ff9bf9..c35e5374 100644
--- a/backend/api/api/Services/ModelService.cs
+++ b/backend/api/api/Services/ModelService.cs
@@ -35,6 +35,10 @@ namespace api.Services
{
return _model.Find(model => model.uploaderId == userId).ToList();
}
+ public List<Model> GetMyModelsByType(string userId, string problemType)
+ {
+ return _model.Find(model => (model.uploaderId == userId && model.type == problemType)).ToList();
+ }
public List<Model> GetLatestModels(string userId)
{
List<Model> list = _model.Find(model => model.uploaderId == userId).ToList();