public ActionResult Index() { BaiHatDAO dao = new BaiHatDAO(); var result = dao.ListOf(); var list = new List <Data.BaiHatModelAdmin>(); foreach (var item in result) { string tenAlbum = item.Album == null ? string.Empty : item.Album.TenAlbum; var bh = new Data.BaiHatModelAdmin(item.IdBaiHat, item.TenBaiHat, item.AnhBaiHat, item.LoiBaihat, item.NgayPhatHanh.HasValue ? item.NgayPhatHanh.Value : DateTime.Now, item.Top100.HasValue ? item.Top100.Value : false, item.LuotNghe.HasValue ? item.LuotNghe.Value : 0, item.LuotTai.HasValue ? item.LuotTai.Value : 0, item.LuotThich.HasValue ? item.LuotThich.Value : 0, item.LinkBaiHat, item.IdNgheSi.HasValue ? item.IdNgheSi.Value : -1, item.IdTheLoai.HasValue ? item.IdTheLoai.Value : -1, item.IdAlbum.HasValue ? item.IdAlbum.Value : -1, tenAlbum, item.NgheSi.TenNgheSi, item.TheLoai.TenTheLoai ); list.Add(bh); } return(View(list)); }
// GET: Home public ActionResult Index() { //Danh Sach Tat Ca Bai Hat BaiHatDAO bh = new BaiHatDAO(); List <BaiHat> ls = bh.ListOf(); ViewBag.NgheGanDay = ls; //Top 15 bai hat hay nhat var top15 = bh.Top15(); ViewBag.Top15 = top15; //Nghệ Sĩ Nổi Bật NgheSiDAO ns = new NgheSiDAO(); var NgheSiHot = ns.ListNgheSiHot(); ViewBag.NgheSiNoiBat = NgheSiHot; //BaiHatMoiPhatHanh var mph = bh.MoiPhatHanh(); ViewBag.MoiPhatHanh = mph; //Album Hot AlbumDAO al = new AlbumDAO(); var album = al.AlbumHot(); ViewBag.AlbumHot = album; //Thể Loại TheLoaiDAO tl = new TheLoaiDAO(); var theloai = tl.TheLoaiListIEnnumable(); ViewBag.TheLoai = theloai; return(View()); }
public JsonResult UpdateView(int id) { BaiHatDAO bh = new BaiHatDAO(); bh.UpdateViews(id); return(Json("Success", JsonRequestBehavior.AllowGet)); }
public ActionResult Detail(int id) { BaiHatDAO dao = new BaiHatDAO(); var result = dao.Detail(id); if (result == null) { ViewBag.Message = "khong tim thay bai hat!"; } if (result != null) { ViewBag.Message = "Thông tin chi tiết bài hát!"; } string tenAlbum = result.Album == null ? string.Empty : result.Album.TenAlbum; Data.BaiHatModelAdmin md = new Data.BaiHatModelAdmin(result.IdBaiHat, result.TenBaiHat, result.AnhBaiHat, result.LoiBaihat, result.NgayPhatHanh.HasValue ? result.NgayPhatHanh.Value : DateTime.Now, result.Top100.HasValue ? result.Top100.Value : false, result.LuotNghe.HasValue ? result.LuotNghe.Value : 0, result.LuotTai.HasValue ? result.LuotTai.Value : 0, result.LuotThich.HasValue ? result.LuotThich.Value : 0, result.LinkBaiHat, result.IdNgheSi.HasValue ? result.IdNgheSi.Value : -1, result.IdTheLoai.HasValue ? result.IdTheLoai.Value : -1, result.IdAlbum.HasValue ? result.IdAlbum.Value : -1, tenAlbum, result.NgheSi.TenNgheSi, result.TheLoai.TenTheLoai); return(View(md)); }
public ActionResult Del(int id) { BaiHatDAO dao = new BaiHatDAO(); dao.Delete(id); return(RedirectToAction("Index", "AdBaiHat")); }
public ActionResult AlbumDetail(int id) { AlbumDAO al = new AlbumDAO(); var album = al.Detail(id); BaiHatDAO bh = new BaiHatDAO(); ViewBag.BaiHatTheoAlbum = bh.BaiHatTheoAlbum(id); return(View(album)); }
public ActionResult ChiTietBaiHat(int id) { BaiHatDAO bh = new BaiHatDAO(); var x = bh.GetBaiHatById2(id); var bhKhac = bh.ListOf(); ViewBag.BaiHatKhac = bhKhac; return(View(x)); }
public ActionResult Update(BaiHat obj, HttpPostedFileBase file, FormCollection f) { BaiHatDAO dao = new BaiHatDAO(); try { if (file != null && file.ContentLength > 0) { string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName += "_" + obj.IdBaiHat; fileName += Path.GetExtension(file.FileName); string folderPath = Server.MapPath("~") + @"\Areas\Admin\Asset\ImagesOutSource\imgsong"; string folderPath2 = Server.MapPath("~") + @"/Assets/images/ImagesOutSource/ImagesSong"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, fileName); string path2 = Path.Combine(folderPath2, fileName); file.SaveAs(path); file.SaveAs(path2); obj.AnhBaiHat = fileName; obj.IdNgheSi = Convert.ToInt32(f["getNgheSi"]); if (dao.Update(obj)) { return(RedirectToAction("Index", "AdBaiHat")); } else { ModelState.AddModelError("", "Error"); return(View(obj.IdBaiHat)); } } else { ModelState.AddModelError("", "Bạn phải nhập vào trường này"); } } catch { } TheLoaiDAO tldao = new TheLoaiDAO(); var category = tldao.ListOf(); NgheSiDAO nsdao = new NgheSiDAO(); var nghesi = nsdao.Listof(); AlbumDAO abdao = new AlbumDAO(); var album = abdao.Listof(); ViewBag.category = category; ViewBag.nghesi = nghesi; ViewBag.album = album; return(View()); }
public FileResult Dowload(int id) { BaiHatDAO bh = new BaiHatDAO(); var data = bh.GetBaiHatById(id); string path = Server.MapPath("~/MusicDowload"); string fileName = Path.GetFileName(data.LinkBaiHat); string fullPath = Path.Combine(path, fileName); return(File(fullPath, "audio/mp3", data.LinkBaiHat)); }
public ActionResult BaiHatTheoTheLoai(int id) { BaiHatDAO bh = new BaiHatDAO(); TheLoaiDAO th = new TheLoaiDAO(); var theloai = th.Detail(id); ViewBag.TheLoai = theloai.TenTheLoai; var x = bh.GetBaiHatByTheLoai(id); return(View(x)); }
public ActionResult ThongTin(int idNgheSi) { NgheSiDAO ns = new NgheSiDAO(); var ngheSi = ns.GetNgheSiById(idNgheSi); BaiHatDAO bh = new BaiHatDAO(); var dsbh = bh.GetBaiHatByIdNgheSi(idNgheSi); ViewBag.BaiHatTheoNgheSi = dsbh; //Nghệ Sĩ Khác ViewBag.NgheSiKhac = ns.ListNgheSiHot().Where(x => x.IdNgheSi != idNgheSi).ToList(); return(View(ngheSi)); }
public JsonResult Index() { BaiHatDAO bh = new BaiHatDAO(); List <BaiHatModel> ls = new List <BaiHatModel>(); var list = bh.ListOf(); for (int i = 0; i < list.Count; i++) { ls.Add(new BaiHatModel(list[i].LinkBaiHat, list[i].IdBaiHat, list[i].AnhBaiHat, list[i].TenBaiHat, list[i].NgheSi.TenNgheSi)); } return(Json(ls, JsonRequestBehavior.AllowGet)); }
public ActionResult Update(int id) { TheLoaiDAO tldao = new TheLoaiDAO(); var category = tldao.ListOf(); NgheSiDAO nsdao = new NgheSiDAO(); var nghesi = nsdao.Listof(); AlbumDAO abdao = new AlbumDAO(); var album = abdao.Listof(); ViewBag.category = category; ViewBag.nghesi = nghesi; ViewBag.album = album; BaiHatDAO dao = new BaiHatDAO(); var rs = dao.Detail(id); return(View(rs)); }
public ActionResult AddDanhSachPhat(int id) { BaiHatDAO bh = new BaiHatDAO(); var data = bh.GetBaiHatById(id); //Tạo Mới Cart Item var cart = Session[CartSession]; if (cart != null) { this.list = (List <DanhSachPhatItem>)cart; if (this.list.Exists(x => x.BaiHat.IdBaiHat == id)) { foreach (var item in this.list.ToList()) { if (item.BaiHat.IdBaiHat == id) { } } } else { var i = new DanhSachPhatItem(); i.BaiHat = data; this.list.Add(i); //Gán vào Session Session[CartSession] = this.list; } } else { var item = new DanhSachPhatItem(); item.BaiHat = data; this.list.Add(item); //Gán vào Session Session[CartSession] = this.list; } return(Json(this.list.Distinct(), JsonRequestBehavior.AllowGet)); }
public ActionResult TatCaBaiHat() { var x = new BaiHatDAO().ListOf(); return(View(x)); }
public ActionResult Add(BaiHat obj, NgheSi obj2, HttpPostedFileBase file, HttpPostedFileBase fileMusic, FormCollection f) { NgheSiDAO dao2 = new NgheSiDAO(); BaiHatDAO dao = new BaiHatDAO(); try { if (file != null && file.ContentLength > 0) { //anh bai hat string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName += "_" + obj.IdBaiHat; fileName += Path.GetExtension(file.FileName); string folderPath = Server.MapPath("~") + @"\Assets\images\ImagesOutSource\ImagesSong"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, fileName); file.SaveAs(path); //anh nghe si string fileName2 = Path.GetFileNameWithoutExtension(fileMusic.FileName); //fileName2 += "_" + obj.LinkBaiHat; fileName2 += Path.GetExtension(fileMusic.FileName); string folderPath2 = Server.MapPath("~") + @"\MusicDowload"; if (!Directory.Exists(folderPath2)) { Directory.CreateDirectory(folderPath2); } string path2 = Path.Combine(folderPath2, fileName2); fileMusic.SaveAs(path2); obj.AnhBaiHat = fileName; obj.LinkBaiHat = fileName2; obj.IdNgheSi = Convert.ToInt32(f["getNgheSi"]); int id = dao.AddNew(obj); if (id != -1) { return(RedirectToAction("Add", "AdBaiHat")); } else { ViewBag.Message("Thêm mới không thành công!"); return(View()); } } else { ModelState.AddModelError("", "Bạn phải nhập vào trường này"); } } catch { } TheLoaiDAO tldao = new TheLoaiDAO(); var category = tldao.ListOf(); NgheSiDAO nsdao = new NgheSiDAO(); var nghesi = nsdao.Listof(); AlbumDAO abdao = new AlbumDAO(); var album = abdao.Listof(); ViewBag.category = category; ViewBag.nghesi = nghesi; ViewBag.album = album; return(View()); }