public IActionResult Post([FromBody] Game model) { model.StartDateTime = DateTime.Now; model.EndDateTime = DateTime.Now.AddMinutes(45); _context.Add(model); _context.SaveChanges(); return(Created("", model)); }
public IActionResult Post([FromBody] Player model) { if (string.IsNullOrEmpty(model.Name) || string.IsNullOrEmpty(model.Country)) { return(StatusCode(400)); } _context.Add(model); _context.SaveChanges(); return(Created("", model)); }
public IActionResult Post([FromBody] ScoreModel model) { var player = _context.Players.Single(c => c.Id == model.PlayerId); var game = _context.Games.Single(c => c.Id == model.GameId); var playerGame = new PlayerGame { Game = game, Player = player, Kills = model.Kills, Deaths = model.Deaths, Assists = model.Assists }; _context.Add(playerGame); _context.SaveChanges(); return(Created("", model)); }