public ActionResult Create(int? team)
        {
            var viewmodel = new CreatePlayerViewModel
            {
                RBI = 0,
                HomeRuns = 0,
                Average = 0,
                TeamId = team
            };

            //items to populate in the drop down list
            viewmodel.TeamSelectList = DropDownHelper.BuildTeamSelectList(_teamDb);

            return View(viewmodel);
        }
        public ActionResult Create(CreatePlayerViewModel viewmodel, HttpPostedFileBase avatar)
        {
            if (ModelState.IsValid)
            {
                Player player = new Player();
                player.Name = viewmodel.Name;
                player.RBI = viewmodel.RBI;
                player.HomeRun = viewmodel.HomeRuns;
                player.Average = viewmodel.Average;

                player.TeamId = viewmodel.TeamId;

                //add new player to the database, after which player.ID is populated
                _playerDb.Add(player);

                if (avatar != null && avatar.ContentLength > 0)
                {
                    AvatarImage image = AvatarUploader.UploadFile2(Server, avatar, player.ID, AvatarTypeEnum.Player);
                    player.AvatarName = image.Name;

                    if (!_playerDb.Update(player))
                    {
                        ModelState.AddModelError("", GenericDatabaseError);
                        viewmodel.TeamSelectList = DropDownHelper.BuildTeamSelectList(_teamDb);
                        return View(viewmodel);
                    }
                }

                return RedirectToAction("Details", new { id = player.ID });
            }

            //this path is reached if the model is initially invalid
            viewmodel.TeamSelectList = DropDownHelper.BuildTeamSelectList(_teamDb);

            return View(viewmodel);
        }