Ejemplo n.º 1
0
        public ActionResult AcceptMatch(AcceptMatchViewModel model)
        {
            if (ModelState.IsValid)
            {
                bool notValid = false;
                var  match    = db.Match.Find(model.MatchId);
                if (!matchManager.MembersGoalsValid(model.MembersGoals, model.Team2Score))
                {
                    notValid           = true;
                    model.MembersGoals = 0;
                    ModelState.AddModelError("accepterror", "Suma strzelonych bramek przez graczy musi być równa liczbie strzelonych bramek przez drużynę");
                    return(RedirectToAction("Index", "Match", model));
                }

                if (!notValid)
                {
                    if (match.MembersGoalsSplitTeam1 == null)
                    {
                        match.MembersGoalsSplitTeam1 = model.MembersGoalsSplit;
                    }
                    else
                    {
                        match.MembersGoalsSplitTeam2 = model.MembersGoalsSplit;
                    }
                    matchManager.AcceptMatch(match);
                    return(RedirectToAction("Index", "Match"));
                }
            }
            return(RedirectToAction("Index", "Match"));
        }