Exemplo n.º 1
0
 public ActionResult Edit(modifAlbum ma)
 {
     if (ModelState.IsValid)
     {
         try
         {
             Album a = depot.Albums.Find(ma.AlbumId);
             a.AnneeParution = ma.AnneeParution;
             a.Artiste       = ma.Artiste;
             a.Description   = ma.Description;
             a.GenreId       = ma.GenreId;
             a.Prix          = ma.Prix;
             a.Titre         = ma.Titre;
             if (ma.image != null)
             {
                 ma.image.SaveAs(Server.MapPath(a.Cover));
             }
             depot.Albums.Update(a);
             return(this.RedirectToAction("Index", "Album"));
         }
         catch (SqlException e)
         {
             ModelState.AddModelError("", e.Message);
         }
     }
     return(View(ma));
 }
Exemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            Album a = depot.Albums.Find(id);
            var   m = new modifAlbum();

            m.AlbumId       = a.AlbumId;
            m.AnneeParution = a.AnneeParution;
            m.Artiste       = a.Artiste;
            m.Description   = a.Description;
            m.Titre         = a.Titre;
            m.Prix          = a.Prix;
            m.GenreId       = a.GenreId;
            return(this.View(m));
        }