public ActionResult Add(MusicGroup group, HttpPostedFileBase coverImage) { BizMusicGroup.Insert(group); if (coverImage != null) { string fileName; string savePath = StringUtility.GetSavePath(group.GroupID, out fileName); fileName = fileName + Path.GetExtension(coverImage.FileName); group.CoverImagePath = savePath + fileName; BizMusicGroup.Update( group.GroupID, g => new MusicGroup { CoverImagePath = group.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 = group.CategoryID, isGroup = true }); }
public ActionResult Edit(MusicGroup group, HttpPostedFileBase coverImage) { if (coverImage!=null) { string folder = Settings.Default.MusicGroupCoverImageFolder.Substring(1); MusicGroup mg = BizMusicGroup.Get(group.GroupID); string orgPath = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, folder, mg.CoverImagePath); System.IO.File.Delete(orgPath); string fileName; string savePath = StringUtility.GetSavePath(group.GroupID, out fileName); group.CoverImagePath = savePath + fileName + Path.GetExtension(coverImage.FileName); BizMusicGroup.Update( group.GroupID, g => new MusicGroup { CoverImagePath = group.CoverImagePath } ); string str = string.Format("{0}{1}{2}", AppDomain.CurrentDomain.BaseDirectory, folder, group.CoverImagePath); Directory.CreateDirectory(str); coverImage.SaveAs(str); } BizMusicGroup.Update( group.GroupID, g => new MusicGroup { Description = group.Description, Name = group.Name, Stars = group.Stars, OrderInCategory = group.OrderInCategory } ); return RedirectToAction("Index", "AdminMusicCategory", new { id = group.CategoryID, isGroup = true }); }
partial void DeleteMusicGroup(MusicGroup instance);
partial void UpdateMusicGroup(MusicGroup instance);
partial void InsertMusicGroup(MusicGroup instance);
private void detach_MusicGroup(MusicGroup entity) { this.SendPropertyChanging(); entity.MusicCategory = null; }