create MatchScore update API method

This commit is contained in:
chsakell
2016-10-04 11:21:48 +03:00
parent 9e31c8b135
commit a36624b0bf
4 changed files with 19 additions and 17 deletions

View File

@@ -27,7 +27,7 @@ namespace LiveGameFeed.Controllers
{
_matchRepository = matchRepository;
_feedRepository = feedRepository;
timerService.TimerElapsed += _feed_Generate;
// timerService.TimerElapsed += _feed_Generate;
}
public IActionResult Index()

View File

@@ -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
View 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;}
}
}

View File

@@ -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>();
}
}