// GET: Matches/Create public ActionResult Create() { var vm = new MatchCreateEditViewModel(); vm.FirstTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName)); vm.SecondTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName)); return View(vm); }
// GET: Matches/Create public ActionResult Create() { var vm = new MatchCreateEditViewModel(); vm.FirstTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName)); vm.SecondTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName)); return(View(vm)); }
public ActionResult Edit(MatchCreateEditViewModel vm) { if (ModelState.IsValid) { _uow.Matches.Update(vm.Match); _uow.Commit(); return(RedirectToAction("Index")); } vm.FirstTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.FirstTeamId); vm.SecondTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.SecondTeamId); return(View(vm)); }
public ActionResult Create(MatchCreateEditViewModel vm) { if (ModelState.IsValid) { _uow.Matches.Add(vm.Match); _uow.Commit(); return RedirectToAction("Index"); } vm.FirstTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.FirstTeamId); vm.SecondTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.SecondTeamId); return View(vm); }
// GET: Matches/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Match match = _uow.Matches.GetById(id); if (match == null) { return(HttpNotFound()); } var vm = new MatchCreateEditViewModel() { Match = match }; vm.FirstTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.FirstTeamId); vm.SecondTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.SecondTeamId); return(View(vm)); }
// GET: Matches/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Match match = _uow.Matches.GetById(id); if (match == null) { return HttpNotFound(); } var vm = new MatchCreateEditViewModel() { Match = match }; vm.FirstTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.FirstTeamId); vm.SecondTeamSelectList = new SelectList(_uow.Teams.All, nameof(Team.TeamId), nameof(Team.TeamName), vm.Match.SecondTeamId); return View(vm); }