public void PlayerFormView_InsertItem(Player player)
        {
            if (TryUpdateModel(player))
            {
                try
                {
                    Service.SavePlayer(player);
                    var checkBoxList = PlayerFormView.FindControl("CheckBoxList") as CheckBoxList;

                    //loopar igenom kryssrutorna
                    for (int i = 0; i < checkBoxList.Items.Count; i++)
                    {
                        //om positionen är vald sparas den
                        if (checkBoxList.Items[i].Selected)
                        {
                            var position = new Position();
                            position.PlTypeID = byte.Parse(checkBoxList.Items[i].Value);
                            position.PlayerID = player.PlayerID;
                            Service.SavePosition(position);
                        }
                    }

                    Page.SetTempData("successMessage", "The player was inserted!");
                    Response.RedirectToRoute("Details", new { id = player.PlayerID });
                    Context.ApplicationInstance.CompleteRequest();

                }

                catch
                {
                    ModelState.AddModelError(String.Empty, "Ett fel inträffade när spelare skulle läggas till");
                }

            }
        }
        public void SavePlayer(Player player)
        {
            ICollection<ValidationResult> validationResults;
            if (!player.ValidatePlayer(out validationResults))
            {
                var ex = new ValidationException("Objektet klarade inte valideringen.");
                ex.Data.Add("ValidationResults", validationResults);
                throw ex;
            }

            if (player.PlayerID == 0)
            {
                PlayerDAL.InsertPlayer(player);
            }

            else
            {
                PlayerDAL.UpdatePlayer(player);
            }
        }
 //spelarens ID skickas som parameter till metoden DeletePlayerID här nedan.
 public void DeletePlayer(Player player)
 {
     DeletePlayerID(player.PlayerID);
 }