コード例 #1
0
        public async Task <IActionResult> CreateGroupBetPlayer(GroupBetPlayerViewModel model)
        {
            if (ModelState.IsValid)
            {
                var path = string.Empty;

                model.GroupBet = await _context.GroupBets
                                 .FirstOrDefaultAsync(p => p.Id == model.GroupBetId);


                //var GroupBetPlayer = _converterHelper.ToGroupBetPlayerEntity(model, path, true);
                //_context.GroupBetPlayers.Add(GroupBetPlayer);
                try
                {
                    await _context.SaveChangesAsync();

                    return(RedirectToAction($"Details/{model.Id}"));
                }
                catch (Exception ex)
                {
                    if (ex.InnerException.Message.Contains("duplicate"))
                    {
                        ModelState.AddModelError(string.Empty, "Este Jugador ya existe");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, ex.InnerException.Message);
                    }
                }
            }

            //model.GroupBets = _combosHelper.GetComboGroupBets();
            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> CreateGroupBetPlayer(int?id)
        {
            if (id == null)

            {
                return(NotFound());
            }

            var GroupBet = await _context.GroupBets.FindAsync(id.Value);

            if (GroupBet == null)
            {
                return(NotFound());
            }

            var model = new GroupBetPlayerViewModel
            {
                GroupBetId = GroupBet.Id
                             //GroupBets = _combosHelper.GetComboGroupBets()
            };


            return(View(model));
        }