public ActionResult Edit(MusicsList musics, HttpPostedFileBase IMG, HttpPostedFileBase MP3) { MusicsList mus = db.MusicsLists.Find(musics.music_id); musics.music_active = mus.music_active; musics.music_datecreate = mus.music_datecreate; musics.music_dateedit = DateTime.Now; musics.music_bin = mus.music_bin; musics.music_option = mus.music_option; musics.music_view = mus.music_view; musics.music_love = mus.music_love; musics.user_id = mus.user_id; musics.music_dowload = mus.music_dowload; var i = new ImagesController(); if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new ImagesController(); img.AddImages(IMG, Common.Link.IMG_MUSIC, code); musics.music_img = code + IMG.FileName; } else { musics.music_img = mus.music_img; } //Nhạc if (MP3 != null) { var code = Guid.NewGuid().ToString(); var mp3 = new ImagesController(); mp3.AddMP3(MP3, Common.Link.MP3_MUSIC, code); musics.music_linkdow = code + MP3.FileName; } else { musics.music_linkdow = mus.music_linkdow; } var dao = new MusicsDAO(); if (dao.Edit(musics)) { return(Redirect("/Admin/MusicsListAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }
public ActionResult Add(MusicsList musics, HttpPostedFileBase IMG, HttpPostedFileBase MP3, string del) { //Cập nhật có thay đổi musics.music_option = true; musics.music_bin = false; //Kiem tra thay đổi value if (musics.music_active != true && musics.music_active != false) { musics.music_active = false; } //Hinh ảnh if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new ImagesController(); img.AddImages(IMG, Common.Link.IMG_MUSIC, code); musics.music_img = code + IMG.FileName; } else { musics.music_img = "notImg.png"; } //Nhạc if (MP3 != null) { var code = Guid.NewGuid().ToString(); var mp3 = new ImagesController(); mp3.AddMP3(MP3, Common.Link.MP3_MUSIC, code); musics.music_linkdow = code + MP3.FileName; } else { musics.music_linkdow = "NULL"; } var dao = new MusicsDAO(); var j = new JsonAdminController(); if (dao.Add(musics)) { return(Redirect("/Admin/MusicsListAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }