Ejemplo n.º 1
0
 public ExperimentService(IDatabaseContext context)
 {
     _experimentRepository = new ExperimentRepository(context);
     _userRepository       = new UserRepository(context);
     _companyRepository    = new CompanyRepository(context);
     _experimentRepository = new ExperimentRepository(context);
 }
Ejemplo n.º 2
0
 public UnitOfWork()
 {
     _context = new ApplicationContext();
     _distributionRepository           = new DistributionRepository(_context);
     _distributionParametersRepository = new DistributionParametersRepository(_context);
     _experimentRepository             = new ExperimentRepository(_context);
     _percentageRepository             = new PercentageRepository(_context);
 }
Ejemplo n.º 3
0
        public ExperimentService()
        {
            var context = new DatabaseContext();

            _userRepository       = new UserRepository(context);
            _companyRepository    = new CompanyRepository(context);
            _experimentRepository = new ExperimentRepository(context);
        }
        public async Task <IActionResult> DeleteExperiment([FromRoute] Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await ExperimentRepository.DeleteAsync(id);

            return(Ok());
        }
        public async Task <IActionResult> PostExperimentSettings([FromBody] ExperimentSettings experimentSettings)
        {
            experimentSettings.LogicalName = "experiment_settings";
            experimentSettings.CreatedOn   = DateTime.Now;
            experimentSettings.Experiment  = await ExperimentRepository.GetByIdAsync(experimentSettings.ExperimentId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            experimentSettings = await ExperimentService.CreateSettingsAsync(experimentSettings);

            return(CreatedAtAction("GetExperimentSettings", new { id = experimentSettings.Id }, experimentSettings));
        }
        public async Task <IActionResult> PutExperiment([FromRoute] Guid id, [FromBody] Experiment experiment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != experiment.Id)
            {
                return(BadRequest());
            }

            await ExperimentRepository.UpdateAsync(experiment);

            return(NoContent());
        }
        public async Task <IActionResult> GetExperiment([FromRoute] Guid id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var experiment = await ExperimentRepository.GetAsync(id);

            if (experiment == null)
            {
                return(NotFound());
            }

            return(Ok(experiment));
        }
        public async Task <IActionResult> PostExperiment([FromBody] Experiment experiment)
        {
            experiment.LogicalName = "experiment";
            experiment.Name        = experiment.Title;
            experiment.CreatedOn   = DateTime.Now;
            experiment.CreatedBy   = await UserRepository.GetAsync(experiment.CreatedBy.Id);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            experiment = await ExperimentRepository.CreateAsync(experiment);

            return(Ok(experiment.Id));
        }
        public async Task <IActionResult> GetExperimentsByUser([FromQuery] Guid id)
        {
            var result = await ExperimentRepository.GetByUserAsync(id);

            return(Ok(result));
        }
 public async Task <IEnumerable <Experiment> > GetExperiments()
 {
     return(await ExperimentRepository.GetAsync());
 }