aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/api/api/Controllers/ExperimentController.cs21
-rw-r--r--backend/api/api/Models/Experiment.cs1
-rw-r--r--backend/api/api/Services/ExperimentService.cs5
-rw-r--r--backend/api/api/Services/IExperimentService.cs1
4 files changed, 27 insertions, 1 deletions
diff --git a/backend/api/api/Controllers/ExperimentController.cs b/backend/api/api/Controllers/ExperimentController.cs
index 5cf10eb2..7729f8a7 100644
--- a/backend/api/api/Controllers/ExperimentController.cs
+++ b/backend/api/api/Controllers/ExperimentController.cs
@@ -73,6 +73,27 @@ namespace api.Controllers
return Ok(experiment);
}
+ [HttpPost("getMyExperiments")]
+ [Authorize(Roles = "User,Guest")]
+ public async Task<ActionResult<List<Experiment>>> getMyExperiments()
+ {
+ string uploaderId;
+ var header = Request.Headers[HeaderNames.Authorization];
+ if (AuthenticationHeaderValue.TryParse(header, out var headerValue))
+ {
+ var scheme = headerValue.Scheme;
+ var parameter = headerValue.Parameter;
+ uploaderId = jwtToken.TokenToId(parameter);
+ if (uploaderId == null)
+ return null;
+ }
+ else
+ return BadRequest();
+ var experiments=_experimentService.GetMyExperiments(uploaderId);
+ return Ok(experiments);
+
+ }
+
}
diff --git a/backend/api/api/Models/Experiment.cs b/backend/api/api/Models/Experiment.cs
index 688813a0..6de3f169 100644
--- a/backend/api/api/Models/Experiment.cs
+++ b/backend/api/api/Models/Experiment.cs
@@ -18,7 +18,6 @@ namespace api.Models
public float randomTestSetDistribution { get; set; }
public string nullValues { get; set; }
public NullValues[] nullValuesReplacers { get; set; }
- public string fileId { get; set; }
}
}
diff --git a/backend/api/api/Services/ExperimentService.cs b/backend/api/api/Services/ExperimentService.cs
index f7f61136..bf44148c 100644
--- a/backend/api/api/Services/ExperimentService.cs
+++ b/backend/api/api/Services/ExperimentService.cs
@@ -27,5 +27,10 @@ namespace api.Services
{
_experiment.ReplaceOne(experiment => experiment._id == id, experiment);
}
+ public List<Experiment> GetMyExperiments(string id)
+ {
+ return _experiment.Find(e=>e.uploaderId==id).ToList();
+
+ }
}
}
diff --git a/backend/api/api/Services/IExperimentService.cs b/backend/api/api/Services/IExperimentService.cs
index f16f3eae..b18f1ef3 100644
--- a/backend/api/api/Services/IExperimentService.cs
+++ b/backend/api/api/Services/IExperimentService.cs
@@ -6,5 +6,6 @@ namespace api.Services
{
Experiment Create(Experiment experiment);
public Experiment Get(string id);
+ public List<Experiment> GetMyExperiments(string id);
}
} \ No newline at end of file