Example #1
0
        private PhimViewModels Phim2PhimViewModels(Phim p,  int? page = 1,string strSort = "ID", bool isASC = true)
        {
            PhimViewModels pvm = new PhimViewModels();

            pvm.MaSo = p.MaSo;
            pvm.TenPhim = p.TenPhim;
            pvm.NoiDung = p.NoiDung;
            pvm.URL_Trailer = p.URL_Trailer;
            pvm.DiemDanhGia = p.DiemDanhGia;
            pvm.ThoiLuong = p.ThoiLuong;
            pvm.DienVien = p.DienVien;
            pvm.DaoDien = p.DaoDien;
            pvm.HinhAnh = p.HinhAnh;
            pvm.NgayPhatHanh = p.NgayPhatHanh;
            pvm.TheLoai = bus.getTypeOfFilm(p.MS_TheLoai);
            pvm.NuocSX = bus.getCountryOfFilm(p.MS_NuocSX);
            pvm.DiemDanhGiaTrungBinh = bus.calculateAvgRank(p.MaSo);
            pvm.LuotDanhGia = bus.countRateTimes(p.MaSo);
            pvm.Banner = p.AnhBanner;
            pvm.strSort = strSort;
            pvm.currentPage = (int)page;
            pvm.isASC = isASC;

            pvm.MS_TheLoai = (int)p.MS_TheLoai;
            pvm.MS_NuocSX = (int)p.MS_NuocSX;       
            return pvm;
        }
        public ActionResult EditFilm(HttpPostedFileBase file, HttpPostedFileBase banner, String reissue, String genre, String country, String content, String codeFilm, PhimViewModels fvm) {
            String fileName = "";
            if (file != null && file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
                file.SaveAs(path);
            }

            String fileNameBanner = "";
            if (banner != null && banner.ContentLength > 0)
            {
                fileNameBanner = Path.GetFileName(banner.FileName);
                var path = Path.Combine(Server.MapPath("~/Images/"), fileNameBanner);
                banner.SaveAs(path);
            }




            Phim p = new Phim();
            p.MaSo = Int32.Parse(codeFilm);
            p.DiemDanhGia = fvm.DiemDanhGia;
            p.NoiDung = content;
            p.NgayPhatHanh = DateTime.ParseExact(reissue, "MM/dd/yyyy", null); ;
            p.TenPhim = fvm.TenPhim;
            p.TinhTrang = true;
            p.ThoiLuong = fvm.ThoiLuong;
            p.DaoDien = fvm.DaoDien;
            p.DienVien = fvm.DienVien;
            if (genre != "")
                p.MS_TheLoai = Int32.Parse(genre);
            if (country != "")
                p.MS_NuocSX = Int32.Parse(country);
            p.URL_Trailer = fvm.URL_Trailer;


            //Nếu người dùng không upload ảnh mới thì sẽ lấy lại ảnh cũ
            if (fileName != "")
                p.HinhAnh = "/Images/" + fileName;
            else
                p.HinhAnh = (String)TempData["currentAvatar"];


            if (fileNameBanner != "")
                p.AnhBanner = "/Images/" + fileNameBanner;
            else
                p.AnhBanner = (String)TempData["currentBanner"];

            FilmService filmsv = new FilmService();
            filmsv.EditFilm(p);




            return RedirectToAction("Index");
        }
        public ActionResult AddNewFilm(HttpPostedFileBase file, HttpPostedFileBase banner, String reissue,  String genre, String country, String content, PhimViewModels fvm)//String name, String rank, String actor,
        //    String director, String duration, String reissue, String genre, String country, String content, String trailer)
        {
            String fileName = "";
            if (file != null && file.ContentLength > 0)
            {
                fileName = Path.GetFileName(file.FileName);
                var path = Path.Combine(Server.MapPath("~/Images/"), fileName);
                file.SaveAs(path);
            }
            else
            {
                fileName = "defaultAvatar.jpg";
            }


            String fileNameBanner = "";
            if (banner != null && banner.ContentLength > 0)
            {
                fileNameBanner = Path.GetFileName(banner.FileName);
                var path = Path.Combine(Server.MapPath("~/Images/"), fileNameBanner);
                banner.SaveAs(path);
            }
            else
            {
                fileNameBanner = "defaultBanner.jpg";
            }


            Phim p = new Phim();
            p.DiemDanhGia = fvm.DiemDanhGia;
            p.NoiDung = content;
            p.NgayPhatHanh = DateTime.ParseExact(reissue, "MM/dd/yyyy", null); ;
            p.TenPhim = fvm.TenPhim;
            p.TinhTrang = true;
            p.ThoiLuong = fvm.ThoiLuong;
            p.DaoDien = fvm.DaoDien;
            p.DienVien = fvm.DienVien;
            if(genre != "")
            p.MS_TheLoai = Int32.Parse(genre);
            if(country != "")
            p.MS_NuocSX = Int32.Parse(country);
            p.URL_Trailer = fvm.URL_Trailer;
            p.HinhAnh = "/Images/" + fileName;
            p.AnhBanner = "/Images/" + fileNameBanner;
            FilmService filmsv = new FilmService();

            TempData["CreateFilmResult"] = filmsv.addNewFilmd(p);
            return RedirectToAction("CreateFilmResult");
    



           
        }
        public ActionResult CreateNewPost(PhimViewModels phim)
        {
            BaiNhanXet baiNhanXet = new BaiNhanXet();
            baiNhanXet.TinhTrang = true;
            baiNhanXet.MS_Phim = phim.MaSo;
            baiNhanXet.TieuDe = phim.title;
            baiNhanXet.NgayDang = System.DateTime.Now;
            if (phim.contentPost == null)
                phim.contentPost = "";
            baiNhanXet.NoiDung = phim.contentPost;
            baiNhanXet.MS_TaiKhoan = User.Identity.GetUserId();

            ReviewFilmService reviewS = new ReviewFilmService();

            int result = reviewS.addPost(baiNhanXet);


            return RedirectToAction("Index", new {IDPhim =  baiNhanXet.MS_Phim , IDReview= result });
        }
        public ActionResult EditedPost(PhimViewModels phim)
        {

            FilmService bus = new FilmService();

            BaiNhanXet baiNhanXet = new BaiNhanXet();
            baiNhanXet.MaSo = phim.MaSoBaiNhanXet;
            baiNhanXet.TinhTrang = true;
            baiNhanXet.MS_Phim = phim.MaSo;
            baiNhanXet.TieuDe = phim.title;
            baiNhanXet.NgayDang = System.DateTime.Now;
            baiNhanXet.NoiDung = phim.contentPost;
            baiNhanXet.MS_TaiKhoan = User.Identity.GetUserId();

            ReviewFilmService reviewS = new ReviewFilmService();

            bool result = reviewS.editPost(baiNhanXet);

            return RedirectToAction("Index", new { IDPhim = baiNhanXet.MS_Phim, IDReview = phim.MaSoBaiNhanXet });
         
        }
Example #6
0
        public ActionResult PagingMyListFilmLike(int? page)
        {
            FilmLikeService film = new FilmLikeService();
            List<FilmLikeModels> lstFilmLike = film.getMyListFilmLike(User.Identity.GetUserId());

            List<PhimViewModels> result = new List<PhimViewModels>();
       
            PhimViewModels temp = new PhimViewModels();
            FilmService a = new FilmService();
            foreach (FilmLikeModels i in lstFilmLike)
            {
                temp = a.getFilmByMaso(i.ms_phim);
                result.Add(temp);
            }



            int PageSize = 2;
            int pageNumber = page ?? 1;
            return PartialView(result.ToPagedList(pageNumber, PageSize));
        }