public ActionResult TournyEntry(string teams, string regions, string rounds, string ranks) { try { UserHasAccess(Models.Content.TournyEntry); Tourny tournyEntry = new Tourny { Team = new Team { ID = Convert.ToInt32(teams) }, Region = new Region { ID = Convert.ToInt32(regions) }, Rank = Convert.ToInt32(ranks) }; _data.CreateTourny(tournyEntry); List<Team> teamList = _data.GetCurrentTeams(); List<Region> regionList = _data.GetAllRegions(); List<Rank> rankList = _data.GetAllRanks(); List<Tourny> entries = _data.GetAllTournies(); ViewBag.Teams = teamList; ViewBag.Regions = regionList; ViewBag.Ranks = rankList; ViewBag.Tournies = entries; ViewBag.PageMessages = "<span style='color: green'>Success!</span>"; } catch (Exception ex) { ErrorLog.WriteError("Admin TournyEntry", ex.Message); ViewBag.PageMessages = GenericErrorMessage; } return View(); }
public bool CreateTourny(Tourny tourny) { //foreach (Tourny team in tourny) //{ using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["IYFD"].ToString())) { connection.Open(); using (SqlCommand cmd = new SqlCommand("dbo.CreateTourny", connection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@teamID", tourny.Team.ID); cmd.Parameters.AddWithValue("@regionID", tourny.Region.ID); cmd.Parameters.AddWithValue("@rankId", tourny.Rank); cmd.ExecuteNonQuery(); } } //} return true; }