This commit is contained in:
@@ -1,7 +1,30 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using TaxBaik.Application.DTOs;
|
||||
using TaxBaik.Application.Services;
|
||||
using TaxBaik.Web.Services;
|
||||
namespace TaxBaik.Web.Pages.Admin.Blog;
|
||||
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
|
||||
public class CreateModel : PageModel { }
|
||||
|
||||
namespace TaxBaik.Web.Pages.Admin.Blog;
|
||||
|
||||
[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
|
||||
public class CreateModel(BlogService blogService) : PageModel
|
||||
{
|
||||
[BindProperty]
|
||||
public CreateBlogPostDto Input { get; set; } = new()
|
||||
{
|
||||
Content = string.Empty,
|
||||
Title = string.Empty
|
||||
};
|
||||
|
||||
public IActionResult OnGet() => Page();
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(CancellationToken ct)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return Page();
|
||||
|
||||
await blogService.CreateAsync(Input, ct);
|
||||
return RedirectToPage("/Admin/Blog/Index");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user