public async Task <EnvironmentRoot> AddEnvironmentAsync(DesiredState desiredState, CancellationToken cancellationToken = default)
        {
            var environment = _environmentRepository.Add(new EnvironmentRoot(desiredState));

            await _environmentRepository.UnitOfWork.SaveChangesAsync(cancellationToken);

            return(environment);
        }
Ejemplo n.º 2
0
        public ActionResult <EntityBase> Create([FromBody] EnvironmentCreateViewModel Env)
        {
            var newId = _repo.Add(_mapper.Map <Environment>(Env));

            return(Created(nameof(GetById), new EntityBase {
                Id = newId
            }));
        }
        public ActionResult Create([FromBody] EnvironmentViewModel Env)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.SelectMany(e => e.Errors)));
            }

            _repo.Add(_mapper.Map <Domain.Models.Environment>(Env));

            return(CreatedAtAction(nameof(GetById), new { id = Env.Id }, Env));
        }
Ejemplo n.º 4
0
        public ServiceResultModel <Environment> Add(Environment environment)
        {
            var res = new ServiceResultModel <Environment> {
                IsSuccess = false, Errors = new List <string>()
            };

            if (!IsEnvironmentAvailable(environment.EnvironmentName, environment.EnvironmentDescription))
            {
                res.Errors.Add("The Environment Name is already present");
                return(res);
            }


            _environmentRepository.Add(environment);
            UnitOfWork.Commit();

            res.IsSuccess = true;
            res.Data      = environment;
            ;
            return(res);
        }
Ejemplo n.º 5
0
        public EnvironmentViewModel Add(EnvironmentViewModel entity)
        {
            var environment = _repo.Add(_mapper.Map <Environment>(entity));

            return(_mapper.Map <EnvironmentViewModel>(environment));
        }
Ejemplo n.º 6
0
        public async Task <Environment> Add(EnvironmentPostRequest environment, int featureId)
        {
            var entity = mapper.Map <Environment>(environment);

            return(await environmentRepository.Add(entity, featureId));
        }