public ActionResult Edit(int id)
        {
            var service = CreateScoreCardService();
            var detail  = service.GetScoreCardById(id);
            var model   =
                new ScoreCardEdit
            {
                ScoreCardCourseName = detail.ScoreCardCourseName,
                ScoreCardPlayerName = detail.ScoreCardPlayerName,
                //CourseTeeTime = detail.CourseTeeTime
            };

            return(View(model));
        }
Exemple #2
0
        //not nessesary anymore
        public bool UpdateScoreCard(ScoreCardEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .ScoreCards
                    .Single(e => e.ScoreCardId == model.ScoreCardId);

                entity.ScoreCardId = model.ScoreCardId;
                //entity.PlayerList = model.ScoreCardPlayerName;
                //entity.CourseList = model.ScoreCardCourseName;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, ScoreCardEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ScoreCardId != id)
            {
                ModelState.AddModelError("", "Id not matched");
                return(View(model));
            }

            var service = CreateScoreCardService();

            if (service.UpdateScoreCard(model))
            {
                TempData["saveResult"] = "Your Score Card was updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Score Card could not be updated");
            return(View());
        }