public async Task <IActionResult> Create([Bind("MatchID,MatchName")] Match match)
        {
            if (ModelState.IsValid)
            {
                _context.Add(match);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(match));
        }
        public async Task <IActionResult> Create([Bind("PredictionID,TipsterID,MatchID,predictionDate,matchOutcome")] PredictionData prediction)
        {
            if (ModelState.IsValid)
            {
                _context.Add(prediction);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MatchID"]   = new SelectList(_context.Match, "MatchID", "MatchName", prediction.MatchID);
            ViewData["TipsterID"] = new SelectList(_context.Tipster, "TipsterId", "Email", prediction.TipsterID);
            return(View(prediction));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("TipsterId,Name,Email,PhoneNumber")] Tipster tipster)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(tipster);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (DbUpdateException /* ex */)
            {
                //Log the error (uncomment ex variable name and write a log.
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "see your system administrator.");
            }
            return(View(tipster));
        }