コード例 #1
0
        //TODO: need to get settings by user
        public SettingDto GetSettingDto()
        {
            var settingDto = _applicationCasheService.GetValue(ApplicationCasheNames.SettingDto);

            if (settingDto == null)
            {
                var settings = _settingProvider.GetSettings();

                var altRowsColor = settings.ContainsKey(SettingNames.AltRowsColor)
                    ? _serializationService.DeserializeObject <Color>(settings[SettingNames.AltRowsColor])
                    : ColorDefault;

                var dateFormateId = settings.ContainsKey(SettingNames.DateTimeFormat)
                    ? _serializationService.DeserializeObject <int>(settings[SettingNames.DateTimeFormat])
                    : DateTimeFormatDefault;

                var pageSize = settings.ContainsKey(SettingNames.PageSize)
                    ? _serializationService.DeserializeObject <int>(settings[SettingNames.PageSize])
                    : PageSizeDefault;

                var dateFormate = _settingProvider.GetDateFormat(dateFormateId);

                settingDto = new SettingDto
                {
                    DateFormateId    = dateFormateId,
                    AltRowsColor     = altRowsColor,
                    AltRowsColorName = altRowsColor.ToString(),
                    DateTimeFormat   = dateFormate.DateTimeFormat,
                    DateFormat       = dateFormate.ShortDateFormat.ToUpperInvariant(),
                    PageSize         = pageSize
                };

                _applicationCasheService.AddValue(ApplicationCasheNames.SettingDto, settingDto);
            }

            return((SettingDto)settingDto);
        }