public async Task <IActionResult> Edit(int id, [Bind("PointSystemID,CategoryName,MoreOrEqualThanDif,LessOrEqualThanDif,CategoryPoints")] PointSystem pointSystem)
        {
            if (id != pointSystem.PointSystemID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pointSystem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PointSystemExists(pointSystem.PointSystemID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(pointSystem));
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(int id, [Bind("PlayerID,Name,Nickname,WorkDescription")] Player player)
        {
            if (id != player.PlayerID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(player);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerExists(player.PlayerID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(player));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("PredictionID,DayOfPrediction,DateOfPrediction,PlayerName,CasesOfPrediction")] Predictions predictions)
        {
            if (id != predictions.PredictionID)
            {
                return(NotFound());
            }
            var DateOfRealCase = predictions.DateOfPrediction.DayOfWeek;
            var DayOfRealCase  = predictions.DayOfPrediction;

            if (DateOfRealCase == DayOfRealCase)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Update(predictions);
                        try
                        {
                            await _context.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            if (ex.InnerException.Message.Contains("IndexPredictionDate"))
                            {
                                return(View("UniquePredictionDate", predictions));
                            }
                        }
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!PredictionsExists(predictions.PredictionID))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    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));
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("RealCaseID,DayOfRealCases,DateOfRealCases,RealCasesNo")] RealCases realCases)
        {
            if (id != realCases.RealCaseID)
            {
                return(NotFound());
            }
            var DateOfRealCase = realCases.DateOfRealCases.DayOfWeek;
            var DayOfRealCase  = realCases.DayOfRealCases;

            if (DateOfRealCase == DayOfRealCase)
            {
                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Update(realCases);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!RealCasesExists(realCases.RealCaseID))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    return(RedirectToAction(nameof(Index)));
                }
            }
            else
            {
                ModelState.AddModelError("DateOfRealCases", "Date of Real Case does not match with its date of week");
            }

            return(View(realCases));
        }