From a36624b0bf1604b6cc564a9d502ccfaf94838fcf Mon Sep 17 00:00:00 2001 From: chsakell Date: Tue, 4 Oct 2016 11:21:48 +0300 Subject: [PATCH] create MatchScore update API method --- Controllers/HomeController.cs | 2 +- Controllers/MatchesController.cs | 5 +++-- Models/MatchScore.cs | 11 +++++++++++ Startup.cs | 18 ++++-------------- 4 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 Models/MatchScore.cs diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index e75f277..3c8d7a5 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -27,7 +27,7 @@ namespace LiveGameFeed.Controllers { _matchRepository = matchRepository; _feedRepository = feedRepository; - timerService.TimerElapsed += _feed_Generate; + // timerService.TimerElapsed += _feed_Generate; } public IActionResult Index() diff --git a/Controllers/MatchesController.cs b/Controllers/MatchesController.cs index e66380a..a18d3f7 100644 --- a/Controllers/MatchesController.cs +++ b/Controllers/MatchesController.cs @@ -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 diff --git a/Models/MatchScore.cs b/Models/MatchScore.cs new file mode 100644 index 0000000..affe27d --- /dev/null +++ b/Models/MatchScore.cs @@ -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;} + } +} diff --git a/Startup.cs b/Startup.cs index c17084a..0b58ef0 100644 --- a/Startup.cs +++ b/Startup.cs @@ -55,8 +55,7 @@ namespace LiveGameFeed services.AddSignalR(options => options.Hubs.EnableDetailedErrors = true); - services.AddTask(); - services.AddSingleton(); + services.AddTask(); } // 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(TimeSpan.FromSeconds(15)); + app.StartTask(TimeSpan.FromSeconds(15)); } } - public class SampleTask : IRunnable + public class FeedEngine : IRunnable { private ILogger logger; - private SampleTaskRunHistory runHistory; - - public SampleTask(ILogger logger, SampleTaskRunHistory runHistory) + public FeedEngine(ILogger 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 Messages { get; } = new List(); - } }