public virtual ActionResult Edit([Bind(Include = "Id,Name,Active,GamingGroupId")] Player player, ApplicationUser currentUser) { if (ModelState.IsValid) { player.Name = player.Name.Trim(); var requestedPlayer = new UpdatePlayerRequest { PlayerId = player.Id, Active = player.Active, Name = player.Name, }; try { playerSaver.UpdatePlayer(requestedPlayer, currentUser); return(new RedirectResult(Url.Action(MVC.GamingGroup.ActionNames.Index, MVC.GamingGroup.Name) + "#" + GamingGroupController.SECTION_ANCHOR_PLAYERS)); } catch (PlayerAlreadyExistsException) { ModelState.AddModelError(string.Empty, $@"A Player with name '{requestedPlayer.Name}' already exists in this Gaming Group. Choose another."); } } var playerEditViewModel = playerEditViewModelBuilder.Build(player); return(View(MVC.Player.Views.Edit, playerEditViewModel)); }
public virtual HttpResponseMessage UpdatePlayer([FromBody] UpdatePlayerMessage updatePlayerMessage, [FromUri] int playerId, [FromUri] int gamingGroupId) { if (updatePlayerMessage == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "You must pass at least one valid parameter.")); } var requestedPlayer = new UpdatePlayerRequest { PlayerId = playerId, Active = updatePlayerMessage.Active, Name = updatePlayerMessage.PlayerName }; _playerSaver.UpdatePlayer(requestedPlayer, CurrentUser); return(Request.CreateResponse(HttpStatusCode.NoContent)); }
public virtual ActionResult Edit([Bind(Include = "Id,Name,Active,GamingGroupId")] Player player, ApplicationUser currentUser) { if (ModelState.IsValid) { player.Name = player.Name.Trim(); var requestedPlayer = new UpdatePlayerRequest { PlayerId = player.Id, Active = player.Active, Name = player.Name, }; playerSaver.UpdatePlayer(requestedPlayer, currentUser); return(new RedirectResult(Url.Action(MVC.GamingGroup.ActionNames.Index, MVC.GamingGroup.Name) + "#" + GamingGroupController.SECTION_ANCHOR_PLAYERS)); } var playerEditViewModel = playerEditViewModelBuilder.Build(player); return(View(MVC.Player.Views.Edit, playerEditViewModel)); }