Skip to content

Commit

Permalink
Add register new player
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdrm committed Jul 25, 2016
1 parent 09b42dc commit e67a322
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using HabraQuest.Model;
using Microsoft.AspNetCore.Mvc;

namespace HabraQuest.Controllers
{
public class HomeController : Controller
{
private readonly DataContext dataContext;

public HomeController(DataContext db)
{
dataContext = db;
}

public IActionResult Index()
{
return View();
Expand All @@ -17,5 +25,18 @@ public IActionResult Error()
{
return View();
}

public string RegisterNewPlayer()
{
Player player = new Player
{
Token = Guid.NewGuid()
};

dataContext.Add(player);
dataContext.SaveChanges();

return player.Token.ToString();
}
}
}

0 comments on commit e67a322

Please sign in to comment.