From 8b28a4379e149f3e72b3d9d61250f4dd59263edd Mon Sep 17 00:00:00 2001 From: Zizhong Date: Mon, 25 Mar 2019 22:09:02 +1100 Subject: [PATCH] fix missing await on mediator in details razor page --- CoreWiki/Pages/Details.cshtml.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CoreWiki/Pages/Details.cshtml.cs b/CoreWiki/Pages/Details.cshtml.cs index f94841b4..133f6c08 100644 --- a/CoreWiki/Pages/Details.cshtml.cs +++ b/CoreWiki/Pages/Details.cshtml.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using System; -using System.Security.Claims; using System.Threading.Tasks; using MediatR; using AutoMapper; @@ -48,17 +47,17 @@ public async Task OnGetAsync(string slug) Article = _mapper.Map(article); - ManageViewCount(slug); + await ManageViewCount(slug); return Page(); } - private void ManageViewCount(string slug) + private Task ManageViewCount(string slug) { var incrementViewCount = (Request.Cookies[slug] == null); if (!incrementViewCount) { - return; + return Task.FromResult(Unit.Value); } Article.ViewCount++; @@ -67,7 +66,7 @@ private void ManageViewCount(string slug) Expires = DateTime.UtcNow.AddMinutes(5) }); - _mediator.Send(new IncrementViewCountCommand(slug)); + return _mediator.Send(new IncrementViewCountCommand(slug)); } public async Task OnPostAsync(Comment model)