Esempio n. 1
0
        public IActionResult Index()
        {
            var model = new GuitarBuilderViewModel {
                Guitar = new Guitar {
                    Name = "My New Guitar"
                }
            };

            return(View("Index", model));
        }
Esempio n. 2
0
        public async Task <IActionResult> Index(GuitarBuilderViewModel model)
        {
            var adapter = new GuitarBuilderToGuitarAdapter();

            model.Guitar = adapter.BuildGuitar(model);
            await TryUpdateModelAsync(model.Guitar);

            if (ModelState.IsValid)
            {
                return(RedirectToAction("OrderRecieved"));
            }
            return(View("Index", model));
        }