public ActionResult Edit(MatchModel viewModel, Guid ID, int cmbHomeTeamID, int cmbAwayTeamID) { var model = _match.GetDetail(ID); var PartList = PList(model.GroupID); viewModel.GroupID = model.GroupID; viewModel.MatchStatus = 1; ViewBag.ParticipantList1 = new SelectList(PartList, "Value", "Text", _partInMatch.GetMatchHomeParticipant(ID)); ViewBag.ParticipantList2 = new SelectList(PartList, "Value", "Text", _partInMatch.GetMatchAwayParticipant(ID)); _match.Edit(ID, viewModel); _partInMatch.Delete(model.ID); var part1 = new PartInMatchModel { IsHomeTeam = true, MatchID = model.ID, Participant_ID = cmbHomeTeamID }; var part2 = new PartInMatchModel { IsHomeTeam = false, MatchID = model.ID, Participant_ID = cmbAwayTeamID }; _partInMatch.Add(part1); _partInMatch.Add(part2); _uow.SaveChanges(); return(View(model)); }
public void Add(PartInMatchModel viewModel) { var lst = new ParticipantInMatch { IsHomeTeam = viewModel.IsHomeTeam, Match = viewModel.Match, MatchID = viewModel.MatchID, Participant = viewModel.Participant, Participant_ID = viewModel.Participant_ID }; _PartInMatch.Add(lst); }
public virtual async Task <ActionResult> Create(MatchModel viewModel, Guid?GroupID) { ViewBag.StadiumList = STList(); ViewBag.Referee = RList(); ViewBag.ParticipantList = PList(GroupID); if (ModelState.IsValid) { var item = new MatchModel { MatchTime = viewModel.MatchTime, MatchStatus = 0, StadiumID = viewModel.StadiumID, //Referee = _referee.GetDetail(viewModel.RefereeID), RefereeID = viewModel.RefereeID, GroupID = viewModel.GroupID }; var matchID = _match.Add(item); var part1 = new PartInMatchModel { IsHomeTeam = true, MatchID = matchID, Participant_ID = viewModel.HomeTeamID }; var part2 = new PartInMatchModel { IsHomeTeam = false, MatchID = matchID, Participant_ID = viewModel.AwayTeamID }; _partInMatch.Add(part1); _partInMatch.Add(part2); await _uow.SaveChangesAsync(); return(View()); } else { return(View()); } }