Esempio n. 1
0
        public async Task <IActionResult> Edit(int id)
        {
            Match match = await db.Match.FindAsync(id);

            if (match == null)
            {
                return(NotFound());
            }
            else
            {
                EditMatchViewModel model = new EditMatchViewModel {
                    id = id, name = match.name, team1 = match.team1, team2 = match.team2, scoresTeam1 = match.scoresTeam1, scoresTeam2 = match.scoresTeam2
                };
                return(View(model));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(EditMatchViewModel model)
        {
            if (ModelState.IsValid)
            {
                Match match = await db.Match.FindAsync(model.id);

                if (match != null)
                {
                    match.name        = model.name;
                    match.team1       = model.team1;
                    match.team2       = model.team2;
                    match.scoresTeam1 = Convert.ToSByte(model.scoresTeam1);
                    match.scoresTeam2 = Convert.ToSByte(model.scoresTeam2);

                    await db.SaveChangesAsync();

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(View(model));
        }