Exemplo n.º 1
0
        public async Task <IActionResult> Create(OddInputModel oddInputModel)
        {
            var matchId = oddInputModel.MatchId;

            var isMatchValid = this.matchService.IsMatchIdValid(matchId);

            if (!isMatchValid)
            {
                return(this.BadRequest());
            }

            var matchViewModel = this.matchService
                                 .GetAll()
                                 .FirstOrDefault(x => x.Id == matchId);

            var match = this.matchService.GetMatch(matchId);

            var odd = new Odd
            {
                Match    = match,
                OddValue = oddInputModel.OddValue,
                Type     = oddInputModel.Type
            };

            await this.oddRepository.AddAsync(odd);

            await this.oddRepository.SaveChangesAsync();


            return(this.RedirectToAction("All", "Odds"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(OddInputModel model, string id)
        {
            var odd = this.oddRepository.All()
                      .FirstOrDefault(x => x.Id == id);

            var match = this.matchService.GetMatch(model.MatchId);

            mapper.Map(model, odd);
            odd.Match = match;

            await this.oddRepository.SaveChangesAsync();

            return(this.RedirectToAction("All", "Odds"));
        }