コード例 #1
0
        public ActionResult UserLeagueEdit(UserLeagueEdit model)
        {
            var service = CreateLeagueService();


            service.UpdateUserLeagueScore(model);
            return(RedirectToAction($"PlayLeagueRound/{model.LeagueId}"));
        }
コード例 #2
0
        public ActionResult UserLeagueEdit(string id, int leagueId)
        {
            var service = CreateLeagueService();
            var detail  = service.GetPlayerById(id);
            var model   =
                new UserLeagueEdit
            {
                Score      = detail.Score,
                ID         = detail.Id,
                LeagueId   = leagueId,
                PlayerName = detail.FirstName + " " + detail.LastName
            };

            return(View(model));
        }
コード例 #3
0
        public bool UpdateUserLeagueScore(UserLeagueEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .UserLeagues
                    .SingleOrDefault
                        (e => e.UserId == model.ID && e.LeagueId == model.LeagueId);


                if (entity is null)
                {
                    return(false);
                }

                entity.RoundScore = model.Score;
                return(ctx.SaveChanges() == 1);
            }
        }