// GET: WarPicks/Edit/5
        public ActionResult Edit(int id)
        {
            List <ClanWarPickViewModel> picksList = new List <ClanWarPickViewModel>();

            picksList = ClanWarPickViewModel.GetAllByWar(id);

            return(View(picksList));
        }
        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);
        }
Esempio n. 3
0
        private static ClanWarPick ConvertViewToModel(ClanWarPickViewModel viewModel)
        {
            ClanWarPick model = new ClanWarPick();

            model.id                    = viewModel.Id ?? 0;
            model.clanWarId             = viewModel.ClanWarId;
            model.clanMemberWarPosition = viewModel.ClanMemberWarPosition;
            model.clanUserId            = viewModel.ClanUserId;
            model.pickVS                = viewModel.PickVS;
            model.note                  = viewModel.Note;
            model.addedOn               = viewModel.AddedOn;
            model.updatedOn             = viewModel.UpdatedOn;

            return(model);
        }
        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;
        }
        private static ClanWarPick ConvertViewToModel(ClanWarPickViewModel viewModel)
        {
            ClanWarPick model = new ClanWarPick();

            model.id = viewModel.Id ?? 0;
            model.clanWarId = viewModel.ClanWarId;
            model.clanMemberWarPosition = viewModel.ClanMemberWarPosition;
            model.clanUserId = viewModel.ClanUserId;
            model.pickVS = viewModel.PickVS;
            model.note = viewModel.Note;
            model.addedOn = viewModel.AddedOn;
            model.updatedOn = viewModel.UpdatedOn;

            return model;
        }