Esempio n. 1
0
        public async Task <ActionResult> SetScore(SetScoreViewModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    ModelState.AddModelError("", "Set Scores: Model state is invalid");
                    return(View(model));
                }
                if (model.Id == null)
                {
                    ModelState.AddModelError("", "Set Scores: No ID");
                    return(View(model));
                }
                GameGolfer gameGolfer = await _gameGolferRepo.FindByID(model.Id);

                gameGolfer.Score = model.Score;
                var isSuccess = await _gameGolferRepo.Update(gameGolfer);

                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Set Scores: Unable to update the score");
                    return(View(model));
                }
                return(RedirectToAction(nameof(SetScore), new { id = model.GameId }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Set Scores: Something went wrong in setting the score");
                return(View(model));
            }
        }
Esempio n. 2
0
 public async Task <bool> Delete(GameGolfer entity)
 {
     _db.GameGolfers.Remove(entity);
     return(await Save());
 }
Esempio n. 3
0
 public async Task <bool> Update(GameGolfer entity)
 {
     _db.GameGolfers.Update(entity);
     return(await Save());
 }
Esempio n. 4
0
        public async Task <bool> Create(GameGolfer entity)
        {
            await _db.GameGolfers.AddAsync(entity);

            return(await Save());
        }