Example #1
0
        public async Task <IActionResult> AddApplicationSetting([FromBody] ApplicationSettingDto applicationSettingDto)
        {
            if (await applicationSettingRepository.GetApplicationSetting(applicationSettingDto.ApplicationId,
                                                                         applicationSettingDto.SettingId) != null)
            {
                Application application = await applicationRepository.GetApplication(applicationSettingDto.ApplicationId);

                Setting setting = await settingRepository.GetSetting(applicationSettingDto.SettingId);

                return(StatusCode(StatusCodes.Status500InternalServerError,
                                  $"ApplicationSetting with this Application == {application.Name} and" +
                                  $" Setting  == {setting.Name} already exists"));
            }
            ApplicationSetting applicationSetting = new ApplicationSetting(
                applicationSettingDto.ApplicationId
                , applicationSettingDto.SettingId);

            applicationSetting.SetDefaultValue(applicationSettingDto.DefaultValue);
            await applicationSettingRepository.Add(applicationSetting);

            await unitOfWork.SaveEntitiesAsync();

            return(Ok());
        }