Example #1
0
        public async Task <IActionResult> Create([Bind("GM_NOTATION")] Games games)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(games);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "you are done. Bye-bye");
            }
            return(View(games));
        }
        public async Task <IActionResult> Create([Bind("CST_NAME,CST_CREDIT,CST_SEX")] Casters casters)
        {
            try
            {
                if (ModelState.IsValid && (casters.CST_SEX == "M" || casters.CST_SEX == "F"))
                {
                    _context.Add(casters);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                ModelState.AddModelError("", "Something went wrong, check your input data");
            }
            catch
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "you are done. Bye-bye");
            }
            return(View(casters));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("TR_NAME,TR_PRIZEPOOL,TR_DATE_BEG,TR_DATE_END")] Tournaments tournaments)
        {
            try
            {
                DateTime d1 = new DateTime(1900, 1, 1), d2 = DateTime.Now;
                if (ModelState.IsValid && (tournaments.TR_DATE_BEG > d1) && (tournaments.TR_DATE_END < d2) && (tournaments.TR_DATE_BEG < tournaments.TR_DATE_END))
                {
                    _context.Add(tournaments);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                ModelState.AddModelError("", "Something went wrong, check your input data");
            }
            catch
            {
                ModelState.AddModelError("", "Unable to save changes. " +
                                         "Try again, and if the problem persists " +
                                         "you are done. Bye-bye");
            }
            return(View(tournaments));
        }