// Adds WarStat to War Stats Table public static void AddStat(WarStat stat) { Random rand = new Random(); stat.ID = rand.Next(); WarStats.Add(stat); WriteStat(); }
public ActionResult Create(CreateWarViewModel model) { try { if (ModelState.IsValid) { War newWar = new War(); newWar.EnemyClanName = model.EnemyClanName; newWar.EnemyClanTag = model.EnemyClanTag; newWar.Type = model.WarType; newWar.StartDate = model.StartDate; newWar.FinishedFlag = false; WarManager.Add(newWar); List<WarStat> stats = new List<WarStat>(); foreach(string id in model.WarMembers) { int memberId = 0; int.TryParse(id, out memberId); WarStat stat = new WarStat(newWar.ID, memberId); stats.Add(stat); } WarManager.AddStats(stats); } } catch { return View(new CreateWarViewModel()); } return RedirectToAction("EditMode"); }