public async Task <IActionResult> Create([Bind("PointSystemID,CategoryName,MoreOrEqualThanDif,LessOrEqualThanDif,CategoryPoints")] PointSystem pointSystem) { if (ModelState.IsValid) { _context.Add(pointSystem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(pointSystem)); }
public async Task <IActionResult> Create([Bind("PlayerID,Name,Nickname,WorkDescription")] Player player) { if (ModelState.IsValid) { _context.Add(player); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(player)); }
public async Task <IActionResult> Create([Bind("PredictionID,DayOfPrediction,DateOfPrediction,PlayerName,CasesOfPrediction")] Predictions predictions) { var DateOfRealCase = predictions.DateOfPrediction.DayOfWeek; var DayOfRealCase = predictions.DayOfPrediction; if (DateOfRealCase == DayOfRealCase) { if (ModelState.IsValid) { _context.Add(predictions); try { await _context.SaveChangesAsync(); } catch (Exception ex) { if (ex.InnerException.Message.Contains("IndexPredictionDate")) { return(View("UniquePredictionDate", predictions)); } } return(RedirectToAction(nameof(Index))); } } else { ModelState.AddModelError("DateOfPrediction", "Date of Prediction does not match with its date of week"); } var list = new List <User>(); var playerNames = _context.Players.OrderBy(y => y.Name).Select(x => x.Name).ToList(); foreach (var item in playerNames) { list.Add(new User { Key = item, Display = item }); } predictions.PlayersList = new SelectList(list, "Key", "Display"); return(View(predictions)); }
public async Task <IActionResult> Create([Bind("RealCaseID,DayOfRealCases,DateOfRealCases,RealCasesNo")] RealCases realCases) { var DateOfRealCase = realCases.DateOfRealCases.DayOfWeek; var DayOfRealCase = realCases.DayOfRealCases; if (DateOfRealCase == DayOfRealCase) { if (ModelState.IsValid) { _context.Add(realCases); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } else { ModelState.AddModelError("DateOfRealCases", "Date of Real Case does not match with its date of week"); } return(View(realCases)); }