示例#1
0
        public IActionResult CreateSetting(Setting setting)
        {
            if (_settingService.AddSetting(setting))
            {
                return(Created(string.Empty, setting));
            }

            return(BadRequest());
        }
示例#2
0
        public async Task <IActionResult> CreateSetting(SettingDTO create)
        {
            //create.CreatedDate = DateTime.Now;
            if (await _settingService.AddSetting(create))
            {
                return(NoContent());
            }

            throw new Exception("Creating the setting failed on save");
        }
        public async Task Should_Add_Setting()
        {
            var setting = new Setting
            {
                IsVisible = true,
                Key       = Settings.AuthorityVotingRequiredUserPercentage.ToString(),
                Value     = "80"
            };
            await _settingService.AddSetting(setting);

            var getSetting = _context.Settings.FirstOrDefault(x => x.Id == setting.Id);

            Assert.NotNull(getSetting);
            Assert.Equal(setting.IsVisible, getSetting.IsVisible);
            Assert.Equal(setting.Key, getSetting.Key);
            Assert.Equal(setting.Value, getSetting.Value);
        }
示例#4
0
        public async Task <Tenant> AddTenant(Tenant tenant)
        {
            await _tenantRepository.AddTenant(tenant);

            var settings = await _settingService.GetSettings(null);

            foreach (var item in settings)
            {
                if (await _settingService.GetSettingValueByType((Settings)Enum.Parse(typeof(Settings), item.Key),
                                                                tenant.Id) == null)
                {
                    try
                    {
                        var setting = new Setting
                        {
                            IsVisible = item.IsVisible,
                            TenantId  = tenant.Id,
                            Key       = item.Key,
                            Value     = item.Value
                        };
                        await _settingService.AddSetting(setting);
                    }
                    catch (Exception)
                    {
                        // ignored
                    }
                }
            }

            var roleExists = await _roleService.GetRoleByName("Admin", tenant.Id) != null;

            if (!roleExists)
            {
                await _roleService.AddRole("Admin", tenant.Id);
            }
            return(tenant);
        }
 public object AddSetting([FromBody] SettingInputDto setting)
 {
     return(!ModelState.IsValid || setting == null?BadRequest(ModelState) : controller.AddSetting(setting));
 }
 public BasicResponse <SettingInfo> AddSetting(SettingAddRequest settingrequest)
 {
     return(_settingService.AddSetting(settingrequest));
 }