public ActionResult Add(Music music, string lyricWords, HttpPostedFileBase coverImage) { BizMusic.Insert(music); if (coverImage != null) { string fileName; string savePath = StringUtility.GetSavePath(music.MusicID, out fileName); fileName = fileName + Path.GetExtension(coverImage.FileName); music.CoverImagePath = savePath + fileName; BizMusic.Update( music.MusicID, g => new Music { CoverImagePath = music.CoverImagePath } ); string dir = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, Settings.Default.MusicGroupCoverImageFolder.Substring(1), savePath); Directory.CreateDirectory(dir); coverImage.SaveAs(dir + fileName); } return RedirectToAction("Index", "AdminMusicCategory", new { id = music.CategoryID }); }
public ActionResult Edit(Music music, HttpPostedFileBase coverImage) { if (coverImage != null) { string folder = Settings.Default.MusicGroupCoverImageFolder.Substring(1); Music mg = BizMusic.Get(music.MusicID); string orgPath = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, folder, mg.CoverImagePath); System.IO.File.Delete(orgPath); string fileName; string savePath = StringUtility.GetSavePath(music.MusicID, out fileName); fileName = fileName + Path.GetExtension(coverImage.FileName); music.CoverImagePath = savePath + fileName; BizMusic.Update( music.MusicID, g => new Music { CoverImagePath = music.CoverImagePath } ); string dir = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, Settings.Default.MusicGroupCoverImageFolder.Substring(1), savePath); Directory.CreateDirectory(dir); coverImage.SaveAs(dir + fileName); } BizMusic.UpdateAll(music); return RedirectToAction("Index", "AdminMusicCategory", new { id = music.CategoryID }); }
partial void DeleteMusic(Music instance);
partial void UpdateMusic(Music instance);
partial void InsertMusic(Music instance);
private void detach_Music(Music entity) { this.SendPropertyChanging(); entity.MusicCategory = null; }
private void attach_Music(Music entity) { this.SendPropertyChanging(); entity.MusicCategory = this; }