public UserController(IWrapper wrapper, ILogger <UserController> logger, IMapper mapper, SystemSettingsDto settings)
 {
     _repo     = wrapper;
     _logger   = logger;
     _mapper   = mapper;
     _settings = settings;
 }
Exemplo n.º 2
0
        public IActionResult Get()
        {
            //todo:从系统设置项中独立出首页设置选项。因为系统设置项不应当被未经授权的用户完全获取,而只应当获取用于普通用户的必需配置项。
            SystemSettingsDto dto = this._systemSettingsService.ListAsDto();

            return(Json(dto));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> EditSystemSettings([FromBody] SystemSettingsDto systemSettingsResource)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var checkSettings = await _settingsRepo.CheckSystemSettings();

                var settings = await _settingsRepo.GetSystemSettingsModel();

                //edit if exists
                if (checkSettings)
                {
                    //_settingsRepo.Remove(settings); delete
                    _mapper.Map <SystemSettingsDto, SystemSetting>(systemSettingsResource, settings);
                    await _unitOfWork.CompleteAsync();
                }

                settings = await _settingsRepo.GetSystemSettingsModel();

                var result = _mapper.Map <SystemSetting, SystemSettingsDto>(settings);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Error", "An error occured while performing this operation.");
                return(BadRequest(ModelState));
            }
        }
Exemplo n.º 4
0
        public SystemSettingsDto GetSystemSettings()
        {
            Logger.Debug("{0}.GetSystemSettings", GetType().FullName);
            var systemSettingsDom = uow.SystemSettings.Get(ApplicationUser);
            var dto = new SystemSettingsDto(systemSettingsDom);

            dto.smtpAccount.password = null; //Don`t send Password to Client -> Sequrity Risk!
            return(dto);
        }
        public async Task <IActionResult> Update(SystemSettingsDto dto)
        {
            Ensure.NotNull(dto, nameof(dto));
            Ensure.NotNull(dto.Id, nameof(dto));
            Ensure.NotNull(dto.HomepageNews, nameof(dto));

            await this._systemSettingsService.UpdateAsync(dto);

            return(Ok());
        }
        public IActionResult Index()
        {
            var systemSettingsDto = new SystemSettingsDto();

            // General system settings (not persisted)
            systemSettingsDto.EnvironmentName = _hostingEnvironment.EnvironmentName;
            systemSettingsDto.MachineName     = System.Environment.MachineName;

            // Environment specific settings
            if (!_hostingEnvironment.IsProduction())
            {
                systemSettingsDto.DatabaseName = _configurationRoot.GetDatabaseName();
            }

            return(Ok(systemSettingsDto, null));
        }
        public IActionResult List()
        {
            SystemSettingsDto result = this._systemSettingsService.ListAsDto();

            return(Json(result));
        }