コード例 #1
0
 public IActionResult AssignPosition(PlayerPositionsInputVM model)
 {
     for (var i = 0; i < model.Ids.Count(); i++)
     {
         var playerPosition = new PlayerPosition
         {
             PlayerId   = model.PlayerId,
             PositionId = model.Ids[i]
         };
         _dataPlayerPosition.Add(playerPosition);
     }
     return(RedirectToAction(nameof(Index)));
 }
コード例 #2
0
        public IActionResult AssignPosition(int id)
        {
            var player = _dataPlayer.Get(id);

            if (player == null)
            {
                return(RedirectToAction("Error", "Home"));
            }
            var playersPositions = _dataPositions.GetByDetails().Select(x => new SelectListItem
            {
                Text  = x.Name + " - " + x.Abbreviation,
                Value = x.Id.ToString()
            });
            PlayerPositionsInputVM viewModel = new PlayerPositionsInputVM
            {
                PlayerId  = id,
                FirstName = player.FirstName,
                LastName  = player.LastName,
                Positions = playersPositions.ToList()
            };

            return(View(viewModel));
        }