Пример #1
0
        public async Task <IActionResult> OnPostAsync(DateTime recordDate, string?recordName, string recordText)
        {
            recordText ??= @"<p></p>";
            if (recordText.Length == 0)
            {
                recordText = @"<p></p>";
            }
            recordName = recordName?.Trim() ?? "";

            Guid recordId = await _recordsService.AddRecord(DateOnly.FromDateTime(recordDate), recordName, recordText);

            return(RedirectToPage("View", new { recordId }));
        }
Пример #2
0
        public async Task <IActionResult> CreateRecord(CreateRecordDto createDto)
        {
            try
            {
                var recId = await _recordService.AddRecord(createDto.Date, createDto.RecordName, createDto.RecordText);

                if (createDto.ThemesIds.Length > 0)
                {
                    await _recordsThemesService.AddRecordTheme(recId, createDto.ThemesIds);
                }
                var newRecordUri = $@"{await _appSettingsService.GetHostAndPort()}/api/v1.0/records/{recId}";
                return(Created(newRecordUri, recId));
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }