예제 #1
0
        // GET: Admin/Album
        public ActionResult Index()
        {
            AlbumDAO dao = new AlbumDAO();

            var result = dao.Listof();

            return(View(result));
        }
예제 #2
0
        public ActionResult TatCaAlbum()
        {
            AlbumDAO al = new AlbumDAO();
            //Tất cả album
            var allAlbum = al.Listof();

            return(View(allAlbum));
        }
        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 ActionResult Add()
        {
            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());
        }
예제 #5
0
        // GET: Album
        public ActionResult Index()
        {
            AlbumDAO al = new AlbumDAO();
            //Tất cả album
            var allAlbum = al.Listof();

            ViewBag.TatCaAlbum = allAlbum;
            //Album Hot
            var albumHot = al.AlbumHot();

            ViewBag.AlbumHot = albumHot;
            //Bai hát Theo Album
            var listBh = al.BaiHatByAlbum();

            ViewBag.BaiHatTheoAlbum = listBh;
            return(View());
        }
        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 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());
        }