public ActionResult CreateLadder(CreateLadderViewModel model) { // if the model is valid, this will create a new ladder from the model data if (ModelState.IsValid) { Ladder newLadder = new Ladder(); newLadder.Name = model.Name; newLadder.Description = model.Description; newLadder.MatchTypeId = model.MatchTypeId; newLadder.CreationDate = DateTime.UtcNow; newLadder.isActive = model.isActive; newLadder.MaxPlayers = model.MaxPlayers; newLadder.GenderId = model.GenderId; newLadder.MinAge = model.MinAge; newLadder.MaxAge = model.MaxAge; newLadder.MinRating = model.MinRating; newLadder.MaxRating = model.MaxRating; newLadder.UpperChallengeLimit = model.UpperChallengeLimit; newLadder.LowerChallengeLimit = model.LowerChallengeLimit; newLadder.MaxPendingChallenges = model.MaxPendingChallenges; newLadder.MaxQueuedChallenges = model.MaxQueuedChallenges; newLadder.MaxInactiveDays = model.MaxInactiveDays; newLadder.Penalties = model.Penalties; newLadder.InactivityPointLoss = model.InactivityPointLoss; newLadder.MinReqChallenges = model.MinReqChallenges; newLadder.MinChallengeDays = model.MinChallengeDays; newLadder.MinChallengePointLoss = model.MinChallengePointLoss; newLadder.MinReqMatches = model.MinReqMatches; newLadder.MinMatchDays = model.MinMatchDays; newLadder.MinMatchPointLoss = model.MinMatchPointLoss; newLadder.IgnoreAction = model.IgnoreAction; newLadder.IgnorePointLoss = model.IgnorePointLoss; newLadder.MaxIgnoreDays = model.MaxIgnoreDays; newLadder.ChallengeDecline = model.ChallengeDecline; newLadder.MaxDeclines = model.MaxDeclines; newLadder.DeclineDays = model.DeclineDays; newLadder.DeclinePointLoss = model.DeclinePointLoss; newLadder.ForfeitPointLoss = model.ForfeitPointLoss; newLadder.Save(); Success("<strong>Success!</strong> Ladder has been created.", true); //LadderPoints /*These are constant for now, but planning to add admin ability to edit these values later*/ PlayerRatingCollection allratings = PlayerRatingCollection.LoadAll(); foreach(PlayerRating rating in allratings) { LadderPoints pointSet = new LadderPoints { RatingId = rating.Id, LadderId = newLadder.Id, NumStartingPoints = 10, ExpectedWinPoints = 10, ExpectedLossPoints = 5, UnexpectedWinPoints = 20, UnexpectedLossPoints = 10 }; pointSet.Save(); } return RedirectToAction("AllLadders"); } return View(); }