mirror of
https://github.com/chsakell/aspnet-core-signalr-angular.git
synced 2025-12-22 17:27:48 +00:00
create MatchScore update API method
This commit is contained in:
@@ -27,7 +27,7 @@ namespace LiveGameFeed.Controllers
|
||||
{
|
||||
_matchRepository = matchRepository;
|
||||
_feedRepository = feedRepository;
|
||||
timerService.TimerElapsed += _feed_Generate;
|
||||
// timerService.TimerElapsed += _feed_Generate;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
|
||||
@@ -43,9 +43,10 @@ namespace LiveGameFeed.Controllers
|
||||
}
|
||||
|
||||
// POST api/values
|
||||
[HttpPost]
|
||||
public void Post([FromBody]string value)
|
||||
[HttpPost("update", Name = "UpdateScore")]
|
||||
public void UpdateScore([FromBody]MatchScore matchScore)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// PUT api/values/5
|
||||
|
||||
11
Models/MatchScore.cs
Normal file
11
Models/MatchScore.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace LiveGameFeed.Models
|
||||
{
|
||||
public class MatchScore
|
||||
{
|
||||
public int MatchId { get; set; }
|
||||
public int HostScore { get; set; }
|
||||
public int GuestScore {get; set;}
|
||||
}
|
||||
}
|
||||
18
Startup.cs
18
Startup.cs
@@ -55,8 +55,7 @@ namespace LiveGameFeed
|
||||
|
||||
services.AddSignalR(options => options.Hubs.EnableDetailedErrors = true);
|
||||
|
||||
services.AddTask<SampleTask>();
|
||||
services.AddSingleton<SampleTaskRunHistory>();
|
||||
services.AddTask<FeedEngine>();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
@@ -90,32 +89,23 @@ namespace LiveGameFeed
|
||||
|
||||
LiveGameDbInitializer.Initialize(app.ApplicationServices);
|
||||
|
||||
app.StartTask<SampleTask>(TimeSpan.FromSeconds(15));
|
||||
app.StartTask<FeedEngine>(TimeSpan.FromSeconds(15));
|
||||
}
|
||||
}
|
||||
|
||||
public class SampleTask : IRunnable
|
||||
public class FeedEngine : IRunnable
|
||||
{
|
||||
private ILogger logger;
|
||||
|
||||
private SampleTaskRunHistory runHistory;
|
||||
|
||||
public SampleTask(ILogger<SampleTask> logger, SampleTaskRunHistory runHistory)
|
||||
public FeedEngine(ILogger<FeedEngine> logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.runHistory = runHistory;
|
||||
}
|
||||
|
||||
public void Run(TaskRunStatus taskRunStatus)
|
||||
{
|
||||
var msg = string.Format("Run at: {0}", DateTimeOffset.Now);
|
||||
runHistory.Messages.Add(msg);
|
||||
logger.LogDebug(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public class SampleTaskRunHistory
|
||||
{
|
||||
public List<string> Messages { get; } = new List<string>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user