Beispiel #1
0
        public ActionResult <PlantForCreateDto> CreatePlant([FromBody] PlantForCreateDto plant)
        {
            var plantEntity = _mapper.Map <Entities.Plant>(plant);

            _experimentRepository.AddPlant(plantEntity);
            _experimentRepository.Save();

            var plantToReturn = _mapper.Map <PlantDto>(plantEntity);

            return(CreatedAtRoute("GetPlant",
                                  new { plantId = plantToReturn.Id },
                                  plantToReturn));
        }
Beispiel #2
0
        public static void Register(string name, string description, Func <string> identify = null, Func <Experiment, bool> conclude = null, Func <Experiment, IOrderedEnumerable <KeyValuePair <int, double> > > score = null, Func <string, int, int> splitOn = null, object[] alternatives = null, params string[] metrics)
        {
            var experiment = new Experiment(name, description, identify, conclude, score, splitOn, alternatives, metrics);

            ExperimentRepository.Save(experiment);

            foreach (var metric in experiment.Metrics.Select(GetOrRegisterMetric))
            {
                metric.Hook += (sender, args) => Track(experiment, args);
            }
        }
Beispiel #3
0
        public ActionResult <ExperimentForCreateDto> Create(
            Guid plantId, [FromBody] ExperimentForCreateDto experiment)
        {
            if (!_experimentRepository.PlantExists(plantId))
            {
                return(NotFound());
            }

            var experimentEntity = _mapper.Map <Entities.Experiment>(experiment);

            _experimentRepository.AddExperiment(plantId, experimentEntity);
            _experimentRepository.Save();

            var experimentDto = _mapper.Map <ExperimentDto>(experimentEntity);

            return(CreatedAtRoute(
                       "GetExperiment",
                       new { plantId = plantId, experimentId = experimentDto.Id },
                       experimentDto));
        }
 public async Task SaveExperiments(IList <Experiment> experiments)
 {
     await _experimentRepository.Save(experiments);
 }