Exemplo n.º 1
0
        public TopReviewModels BaiNhanXet2BaiNhanXetViewModels(BaiNhanXet topReview)
        {
            
            AccountBus acBus = new AccountBus();
            ReviewFilmsBus bus = new ReviewFilmsBus();
            ThanhVien temp = acBus.getMemberByUserId(topReview.MS_TaiKhoan);

            TopReviewModels result = new TopReviewModels();

            result.UserName = temp.HoTen;
            result.postDate = (DateTime) topReview.NgayDang;

            result.content = topReview.NoiDung;
            result.totalRank = bus.getTotalRank(topReview.MaSo);

            result.title = topReview.TieuDe;
            result.MS_Phim = (int) topReview.MS_Phim;
            result.MS_ReView = (int) topReview.MaSo;

            FilmBus filmBus = new FilmBus();

            Phim p = filmBus.getFilmByID(result.MS_Phim.ToString());
            result.ulr_HinhAnh = p.HinhAnh;
            result.TenPhim = p.TenPhim;
            return result;
        }
Exemplo n.º 2
0
        //Thống kê phần trăm thể loại phim được quan tâm nhiều nhất (Dựa vào số lượng bài nhận xét của từng thể loại phim)
        public Dictionary <string, int> statisticPhimForCountry()
        {
            try
            {
                Dictionary <string, int> result = new Dictionary <string, int>();


                Dictionary <int, int> total         = new Dictionary <int, int>();
                List <BaiNhanXet>     lstBaiNhanXet = db.BaiNhanXet.ToList();


                FilmBus filmBus = new FilmBus();
                foreach (BaiNhanXet baiNhanXet in lstBaiNhanXet)
                {
                    int  MSPhim     = (int)baiNhanXet.MS_Phim;
                    Phim phim       = filmBus.getFilmByID(MSPhim.ToString());
                    int  MS_TheLoai = (int)phim.MS_NuocSX;
                    if (total.ContainsKey(MS_TheLoai))
                    {
                        total[MS_TheLoai]++;
                    }
                    else
                    {
                        total.Add(MS_TheLoai, 1);
                    }
                }
                List <DanhMucNuocSanXuat> lstTheLoai = db.DanhMucNuocSanXuat.Where(x => x.TinhTrang == true).ToList();


                int totalCount = db.BaiNhanXet.ToList().Count();
                foreach (DanhMucNuocSanXuat theLoai in lstTheLoai)
                {
                    DanhMucNuocSanXuat theLoai1 = db.DanhMucNuocSanXuat.Where(x => x.TinhTrang == true && x.MaSo == theLoai.MaSo).FirstOrDefault();

                    if (total.ContainsKey(theLoai.MaSo))
                    {
                        result.Add(theLoai1.TenNuoc, total[theLoai.MaSo]);
                    }

                    else
                    {
                        result.Add(theLoai1.TenNuoc, 0);
                    }
                }

                return(result);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Exemplo n.º 3
0
 internal int[] getStatisticReview()
 {
     FilmBus t = new FilmBus();
     return t.statisticReview();
 }
Exemplo n.º 4
0
 internal Dictionary<string, int> getStatisticPhimForCountry()
 {
     FilmBus t = new FilmBus();
     return t.statisticPhimForCountry();
 }
Exemplo n.º 5
0
        //Thống kê phần trăm thể loại phim được quan tâm nhiều nhất (Dựa vào số lượng bài nhận xét của từng thể loại phim)
        public Dictionary<string, int> statisticPhimForCountry()
        {
            try
            {
                Dictionary<string, int> result = new Dictionary<string, int>();


                Dictionary<int, int> total = new Dictionary<int, int>();
                List<BaiNhanXet> lstBaiNhanXet = db.BaiNhanXet.ToList();


                FilmBus filmBus = new FilmBus();
                foreach (BaiNhanXet baiNhanXet in lstBaiNhanXet)
                {

                    int MSPhim = (int)baiNhanXet.MS_Phim;
                    Phim phim = filmBus.getFilmByID(MSPhim.ToString());
                    int MS_TheLoai = (int)phim.MS_NuocSX;
                    if (total.ContainsKey(MS_TheLoai))
                    {
                        total[MS_TheLoai]++;
                    }
                    else
                    {
                        total.Add(MS_TheLoai, 1);
                    }

                }
                List<DanhMucNuocSanXuat> lstTheLoai = db.DanhMucNuocSanXuat.Where(x=>x.TinhTrang == true).ToList();


                int totalCount = db.BaiNhanXet.ToList().Count();
                foreach (DanhMucNuocSanXuat theLoai in lstTheLoai)
                {
                    DanhMucNuocSanXuat theLoai1 = db.DanhMucNuocSanXuat.Where(x=>x.TinhTrang == true && x.MaSo == theLoai.MaSo).FirstOrDefault();

                    if (total.ContainsKey(theLoai.MaSo))
                    {


                        result.Add(theLoai1.TenNuoc, total[theLoai.MaSo]);
                    }

                    else
                        result.Add(theLoai1.TenNuoc, 0);

                }

                return result;

            }
            catch (Exception e)
            {
                return null;
            }

        }
Exemplo n.º 6
0
        public List<HistoryViewModels> getActivitiesLog(string IDUser)
        {
            //ReviewFilmsBus reviewFilmsBus = new ReviewFilmsBus();
            List<HistoryViewModels> result = new List<HistoryViewModels>();

            CommentBus commentBus = new CommentBus();

            ReviewFilmsBus reviewBus = new ReviewFilmsBus();
            AccountBus accBus = new AccountBus();
            FilmBus filmBus = new FilmBus();
            ThanhVien thanhVien = accBus.getMemberByUserId(IDUser);

            List<BinhLuan> lstBinhLuan = commentBus.getMyComments(IDUser);




            foreach (BinhLuan binhLuan in lstBinhLuan)
            {

                HistoryViewModels temp = new HistoryViewModels();

                BaiNhanXet baiNhanXet = reviewBus.getReview((int)binhLuan.MS_BaiNhanXet);
                Phim phim = filmBus.getFilmByID(baiNhanXet.MS_Phim.ToString());

                temp.tenBaiNhanXet = baiNhanXet.TieuDe;
                temp.MS_BaiNhanXet = (int)binhLuan.MS_BaiNhanXet;
                temp.tenPhim = phim.TenPhim;
                temp.MS_Phim = (int)phim.MaSo;
                temp.action = "Comment";
                temp.Hoten = thanhVien.HoTen;
                temp.content = binhLuan.NoiDung;
                temp.dateAction = (DateTime)binhLuan.NgayDang;
                result.Add(temp);


            }

            FilmLikeBus filmLikeBus = new FilmLikeBus();

            List<DanhSachPhimYeuThich> lstPhimYeuThich = filmLikeBus.getMyListFilmLike(IDUser);


            foreach (DanhSachPhimYeuThich phimYeuThich in lstPhimYeuThich)
            {

                HistoryViewModels temp = new HistoryViewModels();

                Phim p = filmBus.getFilmByID(phimYeuThich.MS_Phim.ToString());
                temp.tenPhim = p.TenPhim;
                temp.MS_Phim = p.MaSo;
                temp.Hoten = thanhVien.HoTen;
                temp.action = "Like";
                temp.content = thanhVien.HoTen + " đã thích " + p.TenPhim;
                temp.dateAction = (DateTime)phimYeuThich.ThoiGian;
                result.Add(temp);


            }


            List<BaiNhanXet> lstNhanXet = reviewBus.getMyListReview(IDUser);

            foreach (BaiNhanXet baiNhanXet in lstNhanXet)
            {

                HistoryViewModels temp = new HistoryViewModels();
                Phim p = filmBus.getFilmByID(baiNhanXet.MS_Phim.ToString());
                temp.tenPhim = p.TenPhim;
                temp.MS_Phim = p.MaSo;
                temp.tenBaiNhanXet = baiNhanXet.TieuDe;
                temp.MS_BaiNhanXet = baiNhanXet.MaSo;
                temp.Hoten = thanhVien.HoTen;
                temp.action = "Post";
                temp.content = thanhVien.HoTen + " đã thêm bài nhận xét ...." + baiNhanXet.MS_Phim;
                temp.dateAction = (DateTime)baiNhanXet.NgayDang;
                result.Add(temp);


            }

            result.Sort((x, y) => y.dateAction.CompareTo(x.dateAction));


            return result;

        }