Ejemplo n.º 1
0
        public ActionResult Edit(Guid?id)
        {
            var game = UnitOfWork.Game.Get(id);

            var model = new GameEditViewModel
            {
                Id          = game.Id,
                Name        = game.Name,
                Description = game.Description,
                Price       = game.Price,
                GenderId    = game.Gender.Id
            };

            model.BindData(UnitOfWork);
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(GameEditViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.BindData(UnitOfWork);
                return(View(model));
            }

            var game = UnitOfWork.Game.Get(model.Id);

            game.Name        = model.Name;
            game.Description = model.Description;
            game.Price       = model.Price;
            game.Gender      = model.GenderId.HasValue ? UnitOfWork.Gender.Get(model.GenderId) : null;

            UnitOfWork.SaveChanges();
            return(RedirectToAction("Index"));
        }