Exemple #1
0
        public ActionResult Edit([Bind(Include = "Id,Name")] GenresEditViewModel genresEditViewModel)
        {
            if (genresEditViewModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (ModelState.IsValid)
            {
                //Use AutoMapper to copy properties.
                Genre genre = Mapper.Map <Genre>(genresEditViewModel);

                _manager.Update(genre);

                return(RedirectToAction("Index"));
            }

            return(View(genresEditViewModel));
        }
Exemple #2
0
        // GET: Genres/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Genre genre = _manager.ReadOne(id.GetValueOrDefault());

            if (genre == null)
            {
                return(HttpNotFound());
            }

            //Use Automapper to copy properties.
            GenresEditViewModel genresEditViewModel = Mapper.Map <GenresEditViewModel>(genre);

            Mapper.Map(genre, genresEditViewModel);

            return(View(genresEditViewModel));
        }