コード例 #1
0
ファイル: VotesController.cs プロジェクト: Crash1988/MVC
        // GET: Votes/Details/5
        public IActionResult Create(int? id, int? teamid, int? matchid)
        {
            Match match = _context.Match.Single(m => m.MatchId == matchid);
            Vote vote = new Vote();
            vote.Match = match;
            string userId = User.GetUserId();
            vote.user = _context.Users.Single(u => u.Id == userId);
            Team team = _context.Team.Single(s => s.TeamId == teamid);
            vote.VotedTeam = team;
            _context.Vote.Add(vote);
            _context.SaveChanges();

            return RedirectToAction("Index");
        }
コード例 #2
0
ファイル: VotesController.cs プロジェクト: Crash1988/MVC
 public IActionResult Editasd(Vote vote)
 {
     if (ModelState.IsValid)
     {
         _context.Update(vote);
         _context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(vote);
 }