diff options
author | Ivan Ljubisavljevic <ivan996sk@gmail.com> | 2022-05-18 21:54:14 +0200 |
---|---|---|
committer | Ivan Ljubisavljevic <ivan996sk@gmail.com> | 2022-05-18 21:54:14 +0200 |
commit | 1b6a8d3a61b0c8afb916043f6b6bd069dac55e57 (patch) | |
tree | f23393d8e1010721db69a29720c02df7e0467fe4 /backend | |
parent | eaa1f809f8e95bd36803e4ff0c89cab420b46cfa (diff) |
GetModelById dodat - upgrade
Diffstat (limited to 'backend')
-rw-r--r-- | backend/api/api/Controllers/DatasetController.cs | 2 | ||||
-rw-r--r-- | backend/api/api/Controllers/ModelController.cs | 20 | ||||
-rw-r--r-- | backend/api/api/Interfaces/IModelService.cs | 1 | ||||
-rw-r--r-- | backend/api/api/Services/ModelService.cs | 5 |
4 files changed, 26 insertions, 2 deletions
diff --git a/backend/api/api/Controllers/DatasetController.cs b/backend/api/api/Controllers/DatasetController.cs index 80c9f2a9..e4741412 100644 --- a/backend/api/api/Controllers/DatasetController.cs +++ b/backend/api/api/Controllers/DatasetController.cs @@ -227,8 +227,6 @@ namespace api.Controllers dataset.fileId = fileModel1._id; - //nesto - dataset.isPreProcess = true; _datasetService.Create(dataset); diff --git a/backend/api/api/Controllers/ModelController.cs b/backend/api/api/Controllers/ModelController.cs index c9e36ca4..39eb7830 100644 --- a/backend/api/api/Controllers/ModelController.cs +++ b/backend/api/api/Controllers/ModelController.cs @@ -149,6 +149,26 @@ namespace api.Controllers return model; } + + // GET api/<ModelController>/byid/{id} + [HttpGet("byid/{id}")] + [Authorize(Roles = "User,Guest")] + public ActionResult<Model> GetModelById(string id) + { + string userId = getUserId(); + + if (userId == null) + return BadRequest(); + + var model = _modelService.GetOneModelById(userId, id); + + if (model == null) + return NotFound($"Model with id = {id} not found"); + + return model; + } + + //odraditi da vraca modele prema nekom imenu diff --git a/backend/api/api/Interfaces/IModelService.cs b/backend/api/api/Interfaces/IModelService.cs index 8c4543de..41cd279c 100644 --- a/backend/api/api/Interfaces/IModelService.cs +++ b/backend/api/api/Interfaces/IModelService.cs @@ -6,6 +6,7 @@ namespace api.Services public interface IModelService { Model GetOneModel(string userId, string name); + Model GetOneModelById(string userId, string name); Model GetOneModel(string id); List<Model> GetMyModels(string userId); List<Model> GetMyModelsByType(string userId, string problemType); diff --git a/backend/api/api/Services/ModelService.cs b/backend/api/api/Services/ModelService.cs index e852d71f..71db6340 100644 --- a/backend/api/api/Services/ModelService.cs +++ b/backend/api/api/Services/ModelService.cs @@ -65,6 +65,11 @@ namespace api.Services return _model.Find(model => model.uploaderId == userId && model.name == name).FirstOrDefault(); } + public Model GetOneModelById(string userId, string id) + { + return _model.Find(model => model.uploaderId == userId && model._id == id).FirstOrDefault(); + } + public Model GetOneModel(string id) { return _model.Find(model => model._id == id).FirstOrDefault(); |