public static ClanWarUpsertViewModel Get(int warId) { Models.ClanWar clanWarInfo = ClanWarManager.SelectByClanWarId(warId); ClanWarUpsertViewModel updateWar = new ClanWarUpsertViewModel(); updateWar.FillModelView(clanWarInfo); return updateWar; }
public static ClanWarUpsertViewModel Get(int warId) { Models.ClanWar clanWarInfo = ClanWarManager.SelectByClanWarId(warId); ClanWarUpsertViewModel updateWar = new ClanWarUpsertViewModel(); updateWar.FillModelView(clanWarInfo); return(updateWar); }
public ActionResult Create() { ClanUser clanUser = HttpContext.GetCurrentLoginInformation(); int clanId = clanUser.clanId != null ? (int)clanUser.clanId : 0; ClanWarUpsertViewModel clanWar = new ClanWarUpsertViewModel(); clanWar.ClanId = clanId; clanWar.WarStartedOn = DateTime.Now.AddDays(1); return View("Edit", clanWar); }
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; }