public ActionResult AddPlayer(PlayersBm model) { var user = User.Identity.Name; if (ModelState.IsValid) { service.AddPlayer(model, user); RedirectToAction("AllPlayers"); } return(this.View(model)); }
public ActionResult <Player> AddPlayer(string name) { try { var newPlayer = _service.AddPlayer(name); if (newPlayer == null) { return(BadRequest("Player already exist or invalid")); } _logger.LogInformation("Created player: {name}", name); return(newPlayer); } catch (Exception) { _logger.LogError("Error creating player"); return(StatusCode(500, "Internal server error")); } }
public IActionResult AddPlayer(int id, [FromBody] PlayerModel player) { var result = _service.AddPlayer(Audit(player)); return(Ok(result)); }