Ejemplo n.º 1
0
        public async Task <IActionResult> Create(string param)
        {
            var model = new BoardGameCreateUpdateViewModel();

            if (await TryUpdateModelAsync(model))
            {
                var newRecord = new BoardGameRecord()
                {
                    MinPlayerAge     = model.MinPlayerAge,
                    MaxPlayersNumber = model.MaxPlayersNumber,
                    MinPlayersNumber = model.MinPlayersNumber,
                    Name             = model.Name
                };

                gameRepository.CreateOrUpdate(newRecord);
            }

            if (ModelState.ErrorCount > 0)
            {
                return(View());
            }

            return(RedirectToAction("Index"));
        }