fixed Article View not adding Reviewer on Submit Review
This commit is contained in:
parent
eb6a9ec88e
commit
1223b7f428
|
@ -4,8 +4,6 @@
|
||||||
@using Wave.Data
|
@using Wave.Data
|
||||||
@using System.Security.Claims
|
@using System.Security.Claims
|
||||||
@using System.Diagnostics.CodeAnalysis
|
@using System.Diagnostics.CodeAnalysis
|
||||||
@using System.Net
|
|
||||||
@using System.Web
|
|
||||||
@using Microsoft.Extensions.Options
|
@using Microsoft.Extensions.Options
|
||||||
|
|
||||||
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
|
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
|
||||||
|
@ -96,6 +94,9 @@
|
||||||
#endregion
|
#endregion
|
||||||
private Article? Article { get; set; }
|
private Article? Article { get; set; }
|
||||||
|
|
||||||
|
[CascadingParameter]
|
||||||
|
public HttpContext HttpContext { get; set; } = default!;
|
||||||
|
|
||||||
private Article GetArticlePublic() {
|
private Article GetArticlePublic() {
|
||||||
if (Article is null) throw new ApplicationException("Article not found.");
|
if (Article is null) throw new ApplicationException("Article not found.");
|
||||||
if (Article.Status >= ArticleStatus.Published && Article.PublishDate <= DateTimeOffset.UtcNow) {
|
if (Article.Status >= ArticleStatus.Published && Article.PublishDate <= DateTimeOffset.UtcNow) {
|
||||||
|
@ -160,6 +161,10 @@
|
||||||
private async Task SubmitForPublish() {
|
private async Task SubmitForPublish() {
|
||||||
await using var context = await ContextFactory.CreateDbContextAsync();
|
await using var context = await ContextFactory.CreateDbContextAsync();
|
||||||
Article!.Status = ArticleStatus.Published;
|
Article!.Status = ArticleStatus.Published;
|
||||||
|
string userId = HttpContext.User.FindFirst("Id")!.Value;
|
||||||
|
if (Article.Author.Id != userId) {
|
||||||
|
Article.Reviewer = await context.Users.FindAsync(userId);
|
||||||
|
}
|
||||||
context.Update(Article);
|
context.Update(Article);
|
||||||
await context.SaveChangesAsync();
|
await context.SaveChangesAsync();
|
||||||
Navigation.NavigateTo("/");
|
Navigation.NavigateTo("/");
|
||||||
|
|
Loading…
Reference in a new issue