예제 #1
0
        public async Task <List <DateListItem> > GetAllDates(DateOnly today)
        {
            var sId                = (await _appSettingsService.GetAppSetting(AppSettingsKey.ImportantDaysScopeId)).value ?? throw new Exception("Setting 'ImportantDaysScopeId' does not exists");
            var scopeId            = Guid.Parse(sId);
            var placeholder        = _appSettingsService.GetHostAndPortPlaceholder();
            var currentHostAndPort = await _appSettingsService.GetHostAndPort();

            var allRecordsIds = _context.Scopes
                                .AsNoTracking()
                                .Where(s => s.Id == scopeId)
                                .SelectMany(s => s.Themes.SelectMany(t => t.RecordsRefs).Select(rr => rr.RecordId))
                                .AsEnumerable();

            var records = await _context.Records
                          .AsNoTracking()
                          .Include(r => r.ThemesRefs)
                          .ThenInclude(tr => tr.Theme)
                          .Where(r => allRecordsIds.Contains(r.Id))
                          .ToListAsync()
                          .ConfigureAwait(false);

            var items = records
                        .Select(r => new DateListItem(
                                    r.Id,
                                    r.Date,
                                    new DateOnly(today.Year, r.Date.Month, r.Date.Day),
                                    string.IsNullOrWhiteSpace(r.Name) ? "[ПУСТО]" : r.Name.Replace(placeholder, currentHostAndPort, StringComparison.OrdinalIgnoreCase),
                                    r.Text?.Replace(placeholder, currentHostAndPort, StringComparison.OrdinalIgnoreCase) ?? "",
                                    string.Join(", ", r.ThemesRefs.Select(tr => tr.Theme !.ThemeName))))
                        .OrderBy(r => r.TransferredDate)
                        .ToList();

            return(items);
        }
예제 #2
0
        public async Task OnGetAsync()
        {
            var(sId, _) = await _settingsSvc.GetAppSetting(AppSettingsKey.StartPageRecordId);

            if (Guid.TryParse(sId, out var id))
            {
                StartPageRecord = await _recordsService.FetchRecordById(id);
            }
        }
예제 #3
0
        public async Task <ActionResult <AppSettingDto> > GetSettings(AppSettingsKey key)
        {
            try
            {
                var(value, modifiedDate) = await _settingsSvc.GetAppSetting(key);

                return(new AppSettingDto
                {
                    Key = key,
                    Value = value ?? "",
                    ModifiedDate = modifiedDate ?? default
                });
            }
예제 #4
0
        public async Task <IActionResult> OnGetAsync()
        {
            var(stringId, _) = await _settingsSvc.GetAppSetting(AppSettingsKey.ImportantDaysScopeId);

            var range = await _settingsSvc.GetAppSettingInt(AppSettingsKey.ImportantDaysDisplayRange);

            if (!Guid.TryParse(stringId, out _) || range == null)
            {
                return(Redirect("~/Dates/Setup"));
            }

            Dates = await _datesService.GetDatesFromRange(Today, true);

            return(Page());
        }
예제 #5
0
        public async Task UpdateViewModel()
        {
            Scopes = await _scopesSvc.GetScopes();

            var(setting, _) = await _settingsSvc.GetAppSetting(AppSettingsKey.ImportantDaysScopeId);

            if (setting != null && Guid.TryParse(setting, out Guid id))
            {
                SelectedScopeId = id;
            }
            else
            {
                SelectedScopeId = Guid.Empty;
            }
            DaysDisplayRange = await _settingsSvc.GetAppSettingInt(AppSettingsKey.ImportantDaysDisplayRange) ?? 20;
        }