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