Exemplo n.º 1
0
 public ActionResult Remove(TeamViewModel teamViewModel, int playerId)
 {
     teamViewModel.Remove(playerId);
     if (teamViewModel.ActionName.Equals("Edit")) return RedirectToAction("Edit", "Team", new { id = teamViewModel.Team.Id });
     if (teamViewModel.ActionName.Equals("Create")) return RedirectToAction("Create", "Team");
     return null;
 }
Exemplo n.º 2
0
 // GET: Team
 public async Task<ActionResult> Index(TeamViewModel teamViewModel = null)
 {
     if(teamViewModel != null) ResetSessions();
     if(teamViewModel == null) teamViewModel = new TeamViewModel();
     await teamViewModel.PopulateData();
     return View("Index", teamViewModel.Teams);
 }
Exemplo n.º 3
0
        public async Task<ActionResult> Create(TeamViewModel teamViewModel,[Bind(Include = "Name, Win, Loss, Draw")] Team team)
        {
            try
            {
                team.Players = teamViewModel.SelectedPlayers;
                await ApiService.PostAsync<Team>(BaseRoute, team);

                return RedirectToAction("Index");
            }
            catch
            {
                ResetSessions();
                return RedirectToAction("Create");
            }
        }
Exemplo n.º 4
0
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            TeamViewModel team = null;
            if (controllerContext.HttpContext.Session != null)
            {
                team = (TeamViewModel)controllerContext.HttpContext.Session[sessionKey];
            }

            if (team == null)
            {
                team = new TeamViewModel();
                if (controllerContext.HttpContext.Session != null)
                {
                    controllerContext.HttpContext.Session[sessionKey] = team;
                }
            }

            return team;
        }
Exemplo n.º 5
0
 public async Task<ActionResult> Edit(TeamViewModel teamViewModel,[Bind(Include = "Id, Name, Win, Loss, Draw")] Team team)
 {
     try
     {
         team.Players = teamViewModel.SelectedPlayers;
         await  ApiService.PutAsync<Team>(BaseRoute + team.Id, team);
         return RedirectToAction("Index");
     }
     catch
     {
         return RedirectToAction("Edit", team.Id);
     }
 }
Exemplo n.º 6
0
  // GET: Team/Edit/5
 public async Task<ActionResult> Edit(TeamViewModel teamViewModel,int id)
  {
      teamViewModel.ActionName = "Edit";
      await teamViewModel.PopulateData(id);
      return View(teamViewModel);
  }
Exemplo n.º 7
0
 // GET: Team/Create
 public async Task<ActionResult> Create(TeamViewModel teamViewModel)
 {
     teamViewModel.ActionName = "Create";
     await teamViewModel.PopulateData();
     return View(teamViewModel);
 }
Exemplo n.º 8
0
 // GET: Team/Details/5
 public async Task<ActionResult> Details(int id, TeamViewModel teamViewModel)
 {
     await teamViewModel.PopulateData(id);
     return View(teamViewModel.Team);
 }
Exemplo n.º 9
0
 // GET: Team/Delete/5
 public async Task<ActionResult> Delete(TeamViewModel teamViewModel,int id)
 {
     await teamViewModel.PopulateData(id);
     return View(teamViewModel.Team);
 }