Beispiel #1
0
        public async Task <bool> AddAsync(AddConfigurationDTO dto)
        {
            var validationResult = new AddNewConfigurationValidator().Validate(dto);

            if (validationResult.IsValid)
            {
                var isExist = _storageProvider.Exists(dto.Name, _applicationName);
                if (!isExist)
                {
                    return(await _storageProvider.AddAsync(new AddStorageConfigurationDTO
                    {
                        Type = dto.Type,
                        IsActive = dto.IsActive,
                        Value = dto.Value,
                        Name = dto.Name,
                        ApplicationName = _applicationName
                    }));
                }
            }

            return(false);
        }
Beispiel #2
0
        public bool Add(AddConfigurationDTO dto)
        {
            var validationResult = new AddNewConfigurationValidator().Validate(dto);

            if (!validationResult.IsValid)
            {
                return(false);
            }

            var isExist = _storageProvider.IsRecordExists(dto.Name, _applicationName);

            if (!isExist)
            {
                return(_storageProvider.Add(new AddConfigurationRepositoryDTO
                {
                    Type = dto.Type,
                    IsActive = dto.IsActive,
                    Value = dto.Value,
                    Name = dto.Name,
                    ApplicationName = _applicationName
                }));
            }
            return(false);
        }
Beispiel #3
0
 public ActionResult <bool> Add([FromBody] AddConfigurationDTO dto)
 {
     return(_configurationEngine.Add(dto));
 }