Ejemplo n.º 1
0
        // GET: GameEvent/Create
        public ActionResult Create(int id)
        {
            var svc         = CreateBlockService();
            var gesvc       = CreateGameEventService();
            var blockDetail = svc.GetBlockByID(id).BlockDetail;
            var model       = new BlockEventViewModel {
                DetailOfBlock = blockDetail
            };

            model.GameEvents = gesvc.GetGameEvents();
            return(View(model));
        }
Ejemplo n.º 2
0
        public bool AddGameEventToBlock(BlockEventViewModel model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.GameEvents.Single(e => e.ID == model.CreateEvent.ID);

                entity.BlockID     = model.DetailOfBlock.ID;
                entity.OwnerID     = _userID;
                entity.TypeOfEvent = GetEventTypeFromString(model.CreateEvent.Type);
                entity.Name        = model.CreateEvent.Name;
                entity.Description = model.CreateEvent.Description;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 3
0
        public ActionResult Create(BlockEventViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateGameEventService();

            if (service.CreateGameEvent(model))
            {
                TempData["SaveResult"] = "Event succesfully added!";
                return(RedirectToAction("Details", "Block", new { id = model.DetailOfBlock.ID }));
            }

            return(View(model));
        }
Ejemplo n.º 4
0
        public bool CreateGameEvent(BlockEventViewModel model)
        {
            var entity = new GameEvent()
            {
                OwnerID     = _userID,
                BlockID     = model.DetailOfBlock.ID,
                TypeOfEvent = GetEventTypeFromString(model.CreateEvent.Type),
                Name        = model.CreateEvent.Name,
                Description = model.CreateEvent.Description
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.GameEvents.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 5
0
        public ActionResult Add(BlockEventViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateGameEventService();

            if (service.AddGameEventToBlock(model))
            {
                TempData["SaveResult"] = "The event was added succesfully.";
                return(RedirectToAction("Details", "Block", new { id = model.DetailOfBlock.ID }));
            }

            ModelState.AddModelError("", "Your event could not be updated.");
            return(View(model));
        }
Ejemplo n.º 6
0
        public ActionResult Add(int eventID, int blockID)
        {
            var svc         = CreateBlockService();
            var gesvc       = CreateGameEventService();
            var blockDetail = svc.GetBlockByID(blockID).BlockDetail;
            var eventDetail = gesvc.GetGameEventByID(eventID, false);
            var model       = new BlockEventViewModel {
                DetailOfBlock = blockDetail
            };

            model.CreateEvent = new GameEventCreate
            {
                ID          = eventDetail.ID,
                Type        = eventDetail.TypeOfEvent,
                Name        = eventDetail.Name,
                Description = eventDetail.Description
            };
            return(View(model));
        }