Esempio n. 1
0
        public ActionResult Create()
        {
            var model = new GameCreateViewModel();

            model.BindData(UnitOfWork);
            return(View(model));
        }
Esempio n. 2
0
        public ActionResult Create(GameCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.BindData(UnitOfWork);
                return(View(model));
            }

            var game = new Game()
            {
                Name        = model.Name,
                Description = model.Description,
                Price       = model.Price,
                Gender      = model.GenderId.HasValue ? UnitOfWork.Gender.Get(model.GenderId) : null
            };

            UnitOfWork.Game.Save(game);
            UnitOfWork.SaveChanges();

            return(RedirectToAction("Index"));
        }