Esempio n. 1
0
        public string Adicionar(string nome, List <int> platformIds)
        {
            try
            {
                Game            game      = new Game();
                List <Platform> platforms = new List <Platform>();

                foreach (var platformId in platformIds)
                {
                    platforms.Add(new Platform
                    {
                        PlatformId = platformId
                    });
                }

                game.Nome      = nome;
                game.Platforms = platforms;

                _gameApp.Add(game);

                return(JsonConvert.SerializeObject("OK", Formatting.Indented));
            }
            catch (Exception ex)
            {
                return(JsonConvert.SerializeObject(ex.Message, Formatting.Indented));
            }
        }
Esempio n. 2
0
        public ActionResult Create(GameViewModel game)
        {
            if (ModelState.IsValid)
            {
                var gameDomain = Mapper.Map <GameViewModel, Game>(game);
                _gameAppRepository.Add(gameDomain);

                return(RedirectToAction("Index"));
            }

            return(View(game));
        }
 public ActionResult Create([Bind(Include = "Name, CompanyId")] GameViewModel game)
 {
     try
     {
         _gameAppService.Add(game);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         return(View(game));
     }
 }