@page "/blog/create" @using TaxBaik.Application.Services @using TaxBaik.Domain.Interfaces @attribute [Authorize] @inject BlogService BlogService @inject ICategoryRepository CategoryRepository @inject NavigationManager Navigation @inject Snackbar Snackbar 새 포스트 작성 📝 새 포스트 @foreach (var category in categories) { @category.Name }
저장 취소
@code { private MudForm form; private List categories = []; private CreatePostModel model = new(); protected override async Task OnInitializedAsync() { categories = (await CategoryRepository.GetAllAsync()).ToList(); } private async Task SavePost() { try { await BlogService.CreateAsync(new TaxBaik.Application.DTOs.CreateBlogPostDto { Title = model.Title, Content = model.Content, CategoryId = model.CategoryId, Tags = model.Tags, SeoTitle = model.SeoTitle, SeoDescription = model.SeoDescription, IsPublished = model.IsPublished, AuthorId = 1 // TODO: From session }); Snackbar.Add("포스트가 저장되었습니다.", Severity.Success); Navigation.NavigateTo("/taxbaik/admin/blog"); } catch (Exception ex) { Snackbar.Add($"오류: {ex.Message}", Severity.Error); } } private class CreatePostModel { public string Title { get; set; } public string Content { get; set; } public int CategoryId { get; set; } public string Tags { get; set; } public string SeoTitle { get; set; } public string SeoDescription { get; set; } public bool IsPublished { get; set; } } }