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 });
        }
Example #3
0
 partial void DeleteMusic(Music instance);
Example #4
0
 partial void UpdateMusic(Music instance);
Example #5
0
 partial void InsertMusic(Music instance);
Example #6
0
		private void detach_Music(Music entity)
		{
			this.SendPropertyChanging();
			entity.MusicCategory = null;
		}
Example #7
0
		private void attach_Music(Music entity)
		{
			this.SendPropertyChanging();
			entity.MusicCategory = this;
		}