public static void Create(IMatchService matchService)
        {
            var match = matchService.Create("Napoli", "Roma");

            match.UpdateMatchStatus(MatchStatus.FirstHalf);

            match.UpdateHomeScore("Higuain");
            match.UpdateHomeScore("Higuain");
            match.UpdateHomeScore("Callejon");
            match.UpdateHomeScore("Mertens");

            match.UpdateMatchStatus(MatchStatus.HalfTime);

            matchService.Update(match);

            Console.WriteLine("Half time score {0}", match.Result);

            match.UpdateMatchStatus(MatchStatus.SecondHalf);

            match.UpdateAwayScore("Totti");

            match.UpdateHomeScore("Jorginho");

            match.UpdateMatchStatus(MatchStatus.Ended);

            Console.Write(match.GetMatchStatus());
            Console.WriteLine("Final score {0}", match.Result);

            matchService.Update(match);

            Console.WriteLine("***Some stats***");
            Console.WriteLine("Higuain scored {0} goal", match.GoalsPerHomePlayer("Higuain"));
            Console.WriteLine("Totti scored {0} goal", match.GoalsPerAwayPlayer("Totti"));
        }
Esempio n. 2
0
        public IActionResult Post(MatchDTO dto)
        {
            var input = _mapper.FromDTO(dto);

            var result = _matchService.Create(input);

            return(Ok(_mapper.ToDTO(result)));
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "MatchId,TeamId1,TeamId2,ResultTeam1,ResultTeam2")] Matches matches)
        {
            if (ModelState.IsValid)
            {
                _matchService.Create(matches);
                return(RedirectToAction("Index"));
            }

            ViewBag.TeamId1 = new SelectList(_teamService.GetAll(), "TeamId", "TeamName", matches.TeamId1);
            ViewBag.TeamId2 = new SelectList(_teamService.GetAll(), "TeamId", "TeamName", matches.TeamId2);
            return(View(matches));
        }
Esempio n. 4
0
        public IActionResult PostMatch([FromBody] MatchDTO matchDto)
        {
            // map dto to entity
            var match = mapper.Map <Match>(matchDto);

            try
            {
                // save
                matchService.Create(match);
                return(Ok());
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([FromBody] MatchModel model)
        {
            var loggedUser = LoggedInUser.Current?.Id;

            if (loggedUser.HasValue)
            {
                var user = await _userService.GetAsync(LoggedInUser.Current.Id)
                           .ConfigureAwait(true);

                var matchId = await _matchService.Create(user.Id, model);

                Uri getDetailUri = new Uri(Url.AbsoluteAction("Get", "Team", new { id = matchId }));
                return(Created(getDetailUri, new
                {
                    id = matchId.ToString("N")
                }));
            }
            return(BadRequest());
        }
        public async Task <IActionResult> Post([FromBody] AddMatchViewModel model)
        {
            var round = await _matchService.Create(model);

            return(Json(round.Id));
        }