Ejemplo n.º 1
0
        public ActionResult Details(int id)
        {
            GameModel gameModelFromDb = db.GameModels.Find(id);

            GameModel gameModel = new GameModel()
            {
                Name = gameModelFromDb.Name,
                GameId = gameModelFromDb.GameId
            };

            gameModel.Stages = gameModelFromDb.Stages.Select(stage =>
                 new StageModel()
                 {
                     StageId = stage.StageId,
                     Order = stage.Order,
                     Type = stage.Type,
                     Points = stage.Points.Select(point =>
                         new PointModel()
                         {
                             Latitude = point.Latitude,
                             Longitude = point.Longitude,
                             PointId = point.PointId,
                             StageId = point.StageId,
                         }).ToList(),
                 }).ToList();

            if (!Request.IsAjaxRequest())
            {
                return View(gameModel);
            }
            else
            {
                return this.Json(gameModel, JsonRequestBehavior.AllowGet);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(GameModel gamemodel)
        {
            if (ModelState.IsValid)
            {
                db.GameModels.Add(gamemodel);

                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(gamemodel);
        }