コード例 #1
0
        public bool UpdateGameEvent(GameEventEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.GameEvents.Single(e => e.ID == model.ID && e.OwnerID == _userID);

                entity.TypeOfEvent = GetEventTypeFromString(model.TypeOfEvent);
                entity.Name        = model.Name;
                entity.Description = model.Description;

                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #2
0
        // GET: GameEvent/Edit/5
        public ActionResult Edit(int id)
        {
            var service = CreateGameEventService();
            var detail  = service.GetGameEventByID(id, false);
            var model   = new GameEventEdit
            {
                ID          = detail.ID,
                BlockID     = detail.BlockID,
                MapID       = detail.MapID,
                Creator     = detail.Creator,
                TypeOfEvent = detail.TypeOfEvent,
                Name        = detail.Name,
                Description = detail.Description
            };

            return(View(model));
        }
コード例 #3
0
        public ActionResult Edit(int id, GameEventEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ID != id)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }

            var service = CreateGameEventService();

            if (service.UpdateGameEvent(model))
            {
                TempData["SaveResult"] = "The event was updated succesfully.";
                return(RedirectToAction("Details", "Block", new { id = model.BlockID }));
            }

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