diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/api/api/Controllers/PredictorController.cs | 30 | ||||
-rw-r--r-- | backend/api/api/Models/Model.cs | 2 | ||||
-rw-r--r-- | backend/api/api/Models/NullValues.cs | 9 | ||||
-rw-r--r-- | backend/api/api/Models/Predictor.cs | 16 |
4 files changed, 55 insertions, 2 deletions
diff --git a/backend/api/api/Controllers/PredictorController.cs b/backend/api/api/Controllers/PredictorController.cs index 98e2695e..cdc14632 100644 --- a/backend/api/api/Controllers/PredictorController.cs +++ b/backend/api/api/Controllers/PredictorController.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Net.Http.Headers; using System.Net.Http.Headers; +using System.Diagnostics; namespace api.Controllers { @@ -74,8 +75,8 @@ namespace api.Controllers return _predictorService.SearchPredictors(name, username); } - // GET api/<PredictorController>/{name} - [HttpGet("{id}")] + // GET api/<PredictorController>/getpredictor/{name} + [HttpGet("getpredictor/{id}")] [Authorize(Roles = "User")] public ActionResult<Predictor> GetPredictor(string id) { @@ -185,6 +186,31 @@ namespace api.Controllers } } + // POST api/<PredictorController>/usepredictor {predictor,inputs} + [HttpPost("usepredictor/{id}")] + [Authorize(Roles = "User")] + public ActionResult UsePredictor(String id, [FromBody] String[] inputs) + { + + string username; + var header = Request.Headers[HeaderNames.Authorization]; + if (AuthenticationHeaderValue.TryParse(header, out var headerValue)) + { + var scheme = headerValue.Scheme; + var parameter = headerValue.Parameter; + username = jwtToken.TokenToUsername(parameter); + if (username == null) + return null; + } + else + return BadRequest(); + + Predictor predictor = _predictorService.GetPredictor(username, id); + + foreach(String i in inputs) + Debug.WriteLine(i); + return NoContent(); + } // PUT api/<PredictorController>/{name} diff --git a/backend/api/api/Models/Model.cs b/backend/api/api/Models/Model.cs index 2baab1c0..26f732ee 100644 --- a/backend/api/api/Models/Model.cs +++ b/backend/api/api/Models/Model.cs @@ -46,5 +46,7 @@ namespace api.Models public string nullValues { get; set; } public string[] nullValuesReplacers { get; set; } + + //public NullValues[] nullValues { get; set; } } } diff --git a/backend/api/api/Models/NullValues.cs b/backend/api/api/Models/NullValues.cs new file mode 100644 index 00000000..a8ce4f36 --- /dev/null +++ b/backend/api/api/Models/NullValues.cs @@ -0,0 +1,9 @@ +namespace api.Models +{ + public class NullValues + { + public string column { get; set; } + public string option { get; set; } + public string value { get; set; } + } +} diff --git a/backend/api/api/Models/Predictor.cs b/backend/api/api/Models/Predictor.cs index 568719fc..9c8d362f 100644 --- a/backend/api/api/Models/Predictor.cs +++ b/backend/api/api/Models/Predictor.cs @@ -20,3 +20,19 @@ namespace api.Models } } +/* +{ + "_id" : "6244950f26cf2385bc29ba28", + "username" : "ivan123", + "name" : "Neki prediktor", + "description" : "Neki opis prediktora koji je unet tamo", + "inputs": ["proba", + "proba2", + "proba3" + ], + "output" : "", + "isPublic" : true, + "accessibleByLink" : false, + "dateCreated" : "232" +} +*/
\ No newline at end of file |