public ActionResult Create(Artist artist,int category)
 {
     ArtistPage artistPage = SearchEngine.SearchArtist(artist.Name);
     DomToArtist(artistPage, artist,category);
     db.Artists.Add(artist);
     db.SaveChanges();
     SaveArtistPhoto(artist, artistPage);
     SaveCover(artistPage.AlbumPages, artist.Albums.ToList());
     return Content("新增成功");
 }
Esempio n. 2
0
 public ActionResult Create(Artist artist)
 {
     if (ModelState.IsValid)
     {
         db.Artists.Add(artist);
         db.SaveChanges();
         TempData["createdName"] = artist.Name;
         TempData["createdId"] = artist.Id;
         return RedirectToAction("Artist","Manage");
     }
     return View();
 }
 private void SaveArtistPhoto(Artist artist, ArtistPage artistPage)
 {
     for (int i = 0; i < artistPage.ArtistPhotos.Count; i++)
     {
         Image img=Image.FromStream(HtmlRequestHelper.GetStream(artistPage.ArtistPhotos[i],artistPage.ArtistPhotos[i]));
         img.Save(@"D:\Project\MvcRockShop\Artist\"+artist.Id+"_"+i+".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
         img.Dispose();
     }
 }
 private void DomToArtist(ArtistPage artistPage,Artist artist,int categoryId)
 {
     artist.Albums = DomsToAlbums(artistPage.AlbumPages, categoryId);
 }
Esempio n. 5
0
 public ActionResult Edit(Artist newArtist)
 {
     var oldArtist=db.Artists.FirstOrDefault(artist => artist.Id == newArtist.Id);
     if (oldArtist == null)
     {
         return HttpNotFound();
     }
     if (ModelState.IsValid)
     {
         oldArtist.Name = newArtist.Name;
         db.SaveChanges();
         TempData["success"] = true;
         return RedirectToAction("Edit", new { id = oldArtist.Id });
     }
     return View(newArtist);
 }