Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "PredictorId,Email,LastName,FirstName,Points")] Predictor predictor)
        {
            if (ModelState.IsValid)
            {
                db.Predictors.Add(predictor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(predictor));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "TeamId,Name,Flag")] Team team)
        {
            if (ModelState.IsValid)
            {
                db.Teams.Add(team);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(team));
        }
        public ActionResult Create([Bind(Include = "FixtureId,HomeTeamId,AwayTeamId,GameDate,HomeResult,AwayResult")] Fixture fixture)
        {
            if (ModelState.IsValid)
            {
                db.Fixtures.Add(fixture);
                db.SaveChanges();

                var predictors = db.Predictors.ToList();

                foreach (var predictor in predictors)
                {
                    db.Predictions.Add(new Prediction {
                        PredictorId = predictor.PredictorId, FixtureId = fixture.FixtureId
                    });
                }
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(fixture));
        }
Ejemplo n.º 4
0
        public JsonResult ChangeUser(Prediction model)
        {
            // Update model to your db
            var prediction = db.Predictions.Where(p => p.PredictionId == model.PredictionId).SingleOrDefault();

            // input validation
            if (TryUpdateModel(prediction, "",
                        new string[] { "HomeResult", "AwayResult" }))
            {
                try
                {
                    db.Entry(prediction).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }

            string message = "Success";
            return Json(message, JsonRequestBehavior.AllowGet);
        }