예제 #1
0
        public ActionResult CreateGame(GamesPO form)
        {
            //Declaring local variables
            ActionResult oResponse = RedirectToAction("Index", "Game");

            //Checking if Model state is Valid
            if (ModelState.IsValid)
            {
                try
                {
                    //Mapping in a dataAccess call
                    GamesDO dataObject = GameMapper.MapPoToDo(form);
                    dataAccess.CreateNewGame(dataObject);

                    TempData["Message"] = $"{form.GameName} was created successfully";
                }
                catch (Exception ex)
                {
                    oResponse = View(form);
                }
            }
            else
            {
                oResponse = View(form);
            }

            return(oResponse);
        }
예제 #2
0
        //Method that posts the information for UpdateGame
        public ActionResult UpdateGame(GamesPO form)
        {
            //Declaring local variables
            ActionResult oResponse = RedirectToAction("Index", "Game");

            //Checking if Model state is Valid
            if (ModelState.IsValid)
            {
                try
                {
                    //Mapping in a dataAccess call
                    GamesDO dataObject = GameMapper.MapPoToDo(form);
                    dataAccess.UpdateGames(dataObject);
                }
                catch (Exception ex)
                {
                    oResponse = View(form);
                }
            }
            else
            {
                oResponse = View(form);
            }
            return(oResponse);
        }
        //Mapping GamesPO to GamesDO
        public static GamesDO MapPoToDo(GamesPO from)
        {
            GamesDO to = new GamesDO();

            to.GameID      = from.GameID;
            to.GameName    = from.GameName;
            to.System      = from.System;
            to.Genre       = from.Genre;
            to.ReleaseDate = from.ReleaseDate;
            to.Price       = from.Price;

            return(to);
        }
        public static List <GamesPO> MapDoToPo(List <GamesDO> from)
        {
            List <GamesPO> to = new List <GamesPO>();

            if (from != null)
            {
                foreach (GamesDO item in from)
                {
                    GamesPO mappedItems = MapDoToPo(item);
                    to.Add(mappedItems);
                }
            }
            return(to);
        }
예제 #5
0
        //Method that gets the information for UpdateGame
        public ActionResult UpdateGame(Int64 gameId)
        {
            GamesPO displayObject = new GamesPO();

            try
            {
                //Mapping in a dataAccess call
                GamesDO game = dataAccess.ViewGameAtID(gameId);
                displayObject = GameMapper.MapDoToPo(game);
            }
            catch (Exception ex)
            {
            }
            return(View(displayObject));
        }