Exemplo n.º 1
0
        public ActionResult Edit(string id)
        {
            ArtistViewModel model;
            if(!string.IsNullOrWhiteSpace(id))
            {
                var artist = _artistStore.Get(id);
                model = new ArtistViewModel { Id = artist.Id, Name = artist.Name };
            }
            else
            {
                model = new ArtistViewModel();
            }

            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Edit(ArtistViewModel model)
        {
            if (!ModelState.IsValid)
                return View(model);

            if (!string.IsNullOrWhiteSpace(model.Id))
            {
                var artist = _artistStore.Get(model.Id);
                artist.ChangeName(model.Name);
            }
            else
            {
                _artistStore.Add(model.Name);
            }

            return RedirectToAction("Index");
        }