public ActionResult Edit(ClanWarUpsertViewModel clanWar) { ActionResult result = View(); try { ClanUser clanUser = HttpContext.GetCurrentLoginInformation(); int clanWarId = ClanWarManager.Upsert(clanWar, clanUser.id); if (clanWarId > 0) { //Insert member picks //vv List<WarRanking> rankings = new List<WarRanking>(); List <ClanWarPickViewModel> picks = new List <ClanWarPickViewModel>(); List <ClanUser> clanMembers = ClanUserManager.SelectAllByClanId(clanWar.ClanId); short i = 1; foreach (ClanUser member in clanMembers) { WarRanking ranking = new WarRanking() { clanUserId = member.id, clanWarId = clanWarId }; //vv rankings.Add(ranking); ClanWarPickViewModel pick = new ClanWarPickViewModel() { ClanUserId = member.id, ClanMemberWarPosition = i, ClanWarId = clanWarId, PickVS = i }; picks.Add(pick); i++; } //vv RankingsManager.Upsert(rankings); ClanWarPicksManager.Upsert(picks); } //TODO //vv an Else here should display a message stating that the war was not inserted (and no exception apparently) result = RedirectToAction("Index"); } catch { result = View(clanWar); } return(result); }
public ActionResult Edit(int id, IEnumerable <ClanWarPickViewModel> warPicks) { try { ClanWarPicksManager.Upsert(warPicks.ToList()); return(RedirectToAction("Index", "ClanWar")); } catch { return(View()); } }