Пример #1
0
        public object getTrangCaNhanFlow(int id_user)
        {
            string    Token     = lc.GetHeader(Request);
            LoginData loginData = lc._GetInfoUser(Token);

            if (loginData == null)
            {
                return(JsonResultCommon.DangNhap());
            }
            int    status = 0;
            string Id     = "";

            SqlConditions Conds    = new SqlConditions();
            DataTable     dt       = new DataTable();
            DataTable     dt_group = new DataTable();
            DataTable     dt_user  = new DataTable();

            DataRow[]     dr;
            bool          Visible = true;
            List <object> rs      = new List <object>();
            string        title   = "";

            DataTable dt_token = new DataTable();

            try
            {
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    dt = cnn.CreateDataTable(@"
select  distinct ID_CANHAN,u.ID_USER,AnhBia,UserName,AVATAR,TieuSu
from TBL_TRANGCANHAN as cn, TBL_Account as u where cn.ID_USER=u.ID_USER and u.ID_USER="******"ID_CANHAN"],
                    Id_user    = g["ID_USER"],
                    hinhanhbia = g["AnhBia"],
                    tieusu     = g["TieuSu"],
                    anhbia     = LiteController.genLinkImage_Post(_config.LinkAPI, g["AnhBia"]),
                    //media = g["TYPEPOST"],
                    //imgmedia = $"{link}/UploadedFiles/{g["TYPEPOST"]}",
                    //id_user = r["ID_USER"],

                    user_name = g["UserName"],

                    hinhanh = g["AVATAR"],

                    Avatar = LiteController.genLinkAvatar(_config.LinkAPI, g["AVATAR"]),
                };
                return(JsonResultCommon.ThanhCong(data));
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
Пример #2
0
        public object getDSThongDiepDetail(int id_td)
        {
            int           status   = 0;
            string        Id       = "";
            string        Token    = "";
            SqlConditions Conds    = new SqlConditions();
            DataTable     dt       = new DataTable();
            DataTable     dt_group = new DataTable();
            DataTable     dt_user  = new DataTable();

            DataRow[] dr;


            bool          Visible = true;
            List <object> rs      = new List <object>();
            string        title   = "";

            DataTable dt_token = new DataTable();

            try
            {
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    dt = cnn.CreateDataTable(@"
    select	ID_THONGDIEP,TIEUDE,NOIDUNG,TYPEPOST,CreatedBy,CreatedDate,HOTEN,CHUCVU,AVATAR,COL_DISABLE from TBL_THONGDIEPCEO as td ,
 TBL_USER as u,TBL_NHANVIEN as nv where u.ID_USER=td.CreatedBy and u.IDNV=nv.IDNV and ID_THONGDIEP=" + id_td, Conds);
                }

                var data = from g in dt.AsEnumerable()

                           select new
                {
                    id_thongdiep = g["ID_THONGDIEP"],
                    title        = g["TIEUDE"],
                    noidung      = g["NOIDUNG"],
                    hoten        = g["HOTEN"],
                    chucvu       = g["CHUCVU"],
                    media        = g["TYPEPOST"],
                    ghim         = g["COL_DISABLE"],
                    imgmedia     = LiteController.genLinkImage_Post(_config.LinkAPI, g["TYPEPOST"]),
                    //user_name = r["UserName"],
                    create_by  = g["CreatedBy"],
                    createdate = g["CreatedDate"],
                    hinhanh    = g["AVATAR"],
                    AlowEdit   = g["CreatedBy"],
                    Avatar     = LiteController.genLinkAvatar(_config.LinkAPI, g["AVATAR"]),
                };
                return(JsonResultCommon.ThanhCong(data));
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
Пример #3
0
        public object getDSGhim(int id_user)
        {
            int           status   = 0;
            string        Id       = "";
            string        Token    = "";
            SqlConditions Conds    = new SqlConditions();
            DataTable     dt       = new DataTable();
            DataTable     dt_group = new DataTable();
            DataTable     dt_user  = new DataTable();

            DataRow[]     dr;
            bool          Visible = true;
            List <object> rs      = new List <object>();
            string        title   = "";

            DataTable dt_token = new DataTable();

            try
            {
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    dt = cnn.CreateDataTable(@"
SELECT * FROM TBL_GHIM as g,TBL_THONGDIEPCEO as td where g.ID_THONGDIEP=td.ID_THONGDIEP and ID_USER="******"ID_THONGDIEP"],
                    title        = g["TIEUDE"],
                    noidung      = g["NOIDUNG"],
                    media        = g["TYPEPOST"],
                    imgmedia     = LiteController.genLinkImage_Post(_config.LinkAPI, g["TYPEPOST"]),
                    //id_user = r["ID_USER"],

                    //user_name = r["UserName"],
                    create_by  = g["CreatedBy"],
                    createdate = g["CreatedDate"],
                    //hinhanh = g["AVATAR"],
                    //AlowEdit = g["CreatedBy"],
                    //Avatar = $"{link}/Avatar/{  g["AVATAR"]}",
                };
                return(JsonResultCommon.ThanhCong(data));
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
Пример #4
0
        public object getRanDoomAnh()
        {
            int       status    = 0;
            string    Id        = "";
            string    Token     = lc.GetHeader(Request);
            LoginData loginData = lc._GetInfoUser(Token);

            if (loginData == null)
            {
                return(JsonResultCommon.DangNhap());
            }
            SqlConditions Conds    = new SqlConditions();
            DataTable     dt       = new DataTable();
            DataTable     dt_group = new DataTable();
            DataTable     dt_user  = new DataTable();

            DataRow[]     dr;
            bool          Visible = true;
            List <object> rs      = new List <object>();
            string        title   = "";

            DataTable dt_token = new DataTable();

            try
            {
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    dt = cnn.CreateDataTable(@"
 select TOP 1 * from  TBL_BAIDANG where CreatedBy=" + loginData.Id + " and TYPEPOST !=null or TYPEPOST!=''  ORDER BY  NEWID() ", Conds);
                }


                var data = from g in dt.AsEnumerable()

                           select new
                {
                    img     = g["TYPEPOST"],
                    hinhanh = LiteController.genLinkImage_Post(_config.LinkAPI, g["TYPEPOST"]),
                };
                return(JsonResultCommon.ThanhCong(data));
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
        public object getDSBaiDangViewDetail(int id_baidang)
        {
            string    Token     = lc.GetHeader(Request);
            LoginData loginData = lc._GetInfoUser(Token);

            if (loginData == null)
            {
                return(JsonResultCommon.DangNhap());
            }
            PageModel     pageModel = new PageModel();
            string        sql       = "";
            SqlConditions Conds     = new SqlConditions();
            DataTable     dt_group  = new DataTable();

            DataTable dt_baidang = new DataTable();
            DataTable dt_user    = new DataTable();

            DataTable dt_like_baidang = new DataTable();

            DataTable dt_like_comment = new DataTable();
            DataTable dt_comment      = new DataTable();
            DataTable dt_user_comment = new DataTable();
            DataTable dt                = new DataTable();
            DataTable dt_like           = new DataTable();
            DataTable dt_comment_parent = new DataTable();
            DataTable dt_icon           = new DataTable();

            DataTable dt_baidang_like_user = new DataTable();

            DataTable dt_comment_like_user = new DataTable();

            DataTable dt_kt = new DataTable();

            DataRow[] dr;
            // DataRow[] dr;


            try
            {
                ////tesst tam
                //sql = @"select* from TBL_BAIDANG";

                // code dung
                sql = @"
                select ID_BAIDANG,ID_LOAIBAIDANG,TIEUDE,NOIDUNG_BAIDANG,TYPEPOST,CreatedDate,CreatedBy,UpdateDate,UpdateBy,ID_KHENTHUONG,ID_GROUP from TBL_BAIDANG
                ORDER BY ID_BAIDANG DESC";


                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    dt         = cnn.CreateDataTable(sql, Conds);
                    dt_comment = cnn.CreateDataTable(@"select * from TBL_COMMENT");
                    dt_like    = cnn.CreateDataTable(@"select * from TBL_COMMENT");
                    //dt_user_baidang = cnn.CreateDataTable(@"select * from TBL_USER");
                    dt_user = cnn.CreateDataTable(@"select * from TBL_Account");

                    dt_like_baidang = cnn.CreateDataTable(@" 
   select l.ID_LIKE,likebd.ID_BAIDANG, l.title,count(likebd.ID_LIKE) as tong ,l.LINK_ICON from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where
 l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0  group by l.title,likebd.ID_BAIDANG,l.ID_LIKE,l.LINK_ICON
");
                    dt_user_comment = cnn.CreateDataTable(@"select * from TBL_Account");
                    dt_like_comment = cnn.CreateDataTable(@"     select l.ID_LIKE,cmtlike.ID_COMMENT, l.title,count(cmtlike.ID_LIKE) as tong,l.LINK_ICON  from TBL_COMMENT_LIKE as cmtlike ,TBL_LIKE as l where
 l.ID_LIKE=cmtlike.ID_LIKE and cmtlike.COL_DISABLED=0 group by l.title,cmtlike.ID_COMMENT,l.ID_LIKE,l.LINK_ICON   

");

                    dt_icon = cnn.CreateDataTable("select * from TBL_LIKE");

                    dt_baidang_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,likebd.ID_BAIDANG, l.title,l.LINK_ICON,likebd.CREATE_BY,likebd.COL_DISABLED from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where
 l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0
  
");

                    dt_comment_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,like_cmt.ID_COMMENT, l.title,l.LINK_ICON,like_cmt.CREATE_BY  from TBL_COMMENT_LIKE as like_cmt ,TBL_LIKE as l where
 l.ID_LIKE=like_cmt.ID_LIKE and like_cmt.COL_DISABLED=0
");

                    dt_comment_parent = cnn.CreateDataTable(@"  SELECT *
FROM TBL_COMMENT
WHERE ID_COMMENT_PARENT !=0");
                    dt_kt             = cnn.CreateDataTable(@"

select * from TBL_KHENTHUONG
");
                    dt_group          = cnn.CreateDataTable(@"

select ID_GROUP,TEN_GROUP from TBL_GROUP 
");
                }


                var total = dt.Rows.Count;
                if (total == 0)
                {
                    return(JsonResultCommon.ThanhCong(string.Empty, pageModel));
                }



                //  status = 1,
                var data = from r in dt.AsEnumerable()
                           where r["ID_BAIDANG"].Equals(id_baidang)
                           select new
                {
                    Id_BaiDang     = r["ID_BAIDANG"],
                    Id_LoaiBaiDang = r["ID_LOAIBAIDANG"],
                    title          = r["TIEUDE"],
                    NoiDung        = r["NOIDUNG_BAIDANG"],
                    CreatedDate    = r["CreatedDate"],
                    CreatedBy      = r["CreatedBy"],
                    hinhanh        = r["TYPEPOST"],
                    image          = LiteController.genLinkImage_Post(_config.LinkAPI, r["TYPEPOST"]),
                    //Id_Group = r["ID_GROUP"],
                    UpdateDate    = r["UpdateDate"],
                    UpdateBy      = r["UpdateBy"],
                    id_khenthuong = r["ID_KHENTHUONG"],
                    AllowEdit     = r["CreatedBy"],

                    Group = from g in dt_group.AsEnumerable()
                            where r["ID_GROUP"].Equals(g["ID_GROUP"])
                            select new
                    {
                        id_group  = g["ID_GROUP"],
                        ten_group = g["TEN_GROUP"],
                        //icon = g["LINK_ICON"],
                    },

                    // bai dang duoc like

                    KhenThuong = from kt in dt_kt.AsEnumerable()
                                 where r["ID_KHENTHUONG"].Equals(kt["ID_KHENTHUONG"])
                                 select new
                    {
                        id_khenthuong = kt["ID_KHENTHUONG"],
                        tieude_kt     = kt["TIEUDE"],
                        icon          = kt["LINK_ICON"],
                    },


                    Like = (
                        from lr in dt_baidang_like_user.AsEnumerable()
                        where lr["ID_BAIDANG"].Equals(r["ID_BAIDANG"]) && lr["CREATE_BY"].Equals(loginData.Id)
                        //&& lr["CreatedBy"].Equals(r["CreatedBy"]))
                        select new
                    {
                        CreateBy = lr["CREATE_BY"],
                        ID_like = lr["ID_LIKE"],
                        title = lr["title"],
                        icon = lr["LINK_ICON"],
                        //icon_app = lr["ICON_APP"]
                    }).FirstOrDefault(),

                    //Like = ttt,
                    Like_BaiDang = from like_bd in dt_like_baidang.AsEnumerable()
                                   where like_bd["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString())
                                   select new
                    {
                        ID_like = like_bd["ID_LIKE"],
                        title   = like_bd["title"],
                        icon    = like_bd["LINK_ICON"],
                        //icon_app= like_bd["ICON_APP"],
                        tong = like_bd["tong"],
                    },
                    User_DangBai = from user in dt_user.AsEnumerable()
                                   where user["ID_USER"].ToString().Equals(r["CreatedBy"].ToString())
                                   select new
                    {
                        ID_user  = user["ID_USER"],
                        Username = user["UserName"],
                        ID_NV    = user["IDNV"],
                        hinhanh  = user["AVATAR"],
                        avatar   = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]),
                    },
                    // Trong bai dang co nhung commet nao
                    Coment = from h in dt_comment.AsEnumerable()
                             where h["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString())
                             select new
                    {
                        id_cmt     = h["ID_COMMENT"],
                        Id_BaiDang = h["ID_BAIDANG"],

                        NoiDung_cmt   = h["NOIDUNG_COMMENT"],
                        typepost      = h["TYPEPOST"],
                        CreatedBy     = h["CreatedBy_cmt"],
                        CreatedDate   = h["CreatedDate_cmt"],
                        id_cmt_parent = h["ID_COMMENT_PARENT"],
                        //Dan_Nhan = h["ID_DANNHAN"],
                        UpdatedDate = h["UpdatedDate_cmt"],
                        UpdatedBy   = h["UpdatedBy_cmt"],
                        AllowEdit   = h["CreatedBy_cmt"],

                        User_comment = from user in dt_user.AsEnumerable()
                                       where user["ID_USER"].ToString().Equals(h["CreatedBy_cmt"].ToString())
                                       select new
                        {
                            ID_user  = user["ID_USER"],
                            Username = user["UserName"],
                            ID_NV    = user["IDNV"],
                            hinhanh  = user["AVATAR"],
                            avatar   = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]),
                        },
                        Like = (
                            from lr in dt_comment_like_user.AsEnumerable()
                            where lr["ID_COMMENT"].Equals(h["ID_COMMENT"]) && lr["CREATE_BY"].Equals(loginData.Id)
                            //&& lr["CreatedBy"].Equals(r["CreatedBy"]))
                            select new
                        {
                            CreateBy = lr["CREATE_BY"],
                            ID_like = lr["ID_LIKE"],
                            title = lr["title"],
                            icon = lr["LINK_ICON"],
                            //icon_app = lr["ICON_APP"],
                        }).FirstOrDefault(),
                        Like_Comment = from like_cmt in dt_like_comment.AsEnumerable()
                                       where like_cmt["ID_COMMENT"].ToString().Equals(h["ID_COMMENT"].ToString())
                                       select new
                        {
                            ID_like = like_cmt["ID_LIKE"],
                            title   = like_cmt["title"],
                            icon    = like_cmt["LINK_ICON"],
                            //icon_app = like_cmt["ICON_APP"],
                            tong = like_cmt["tong"],
                        },

                        Comment_child = from like_cmt_chill in dt_comment_parent.AsEnumerable()
                                        where like_cmt_chill["ID_COMMENT_PARENT"].ToString().Equals(h["ID_COMMENT"].ToString())
                                        select new
                        {
                            id_cmt     = like_cmt_chill["ID_COMMENT"],
                            Id_BaiDang = like_cmt_chill["ID_BAIDANG"],

                            NoiDung_cmt     = like_cmt_chill["NOIDUNG_COMMENT"],
                            TypePost        = like_cmt_chill["TYPEPOST"],
                            CreatedBy_cmt   = like_cmt_chill["CreatedBy_cmt"],
                            CreatedDate_cmt = like_cmt_chill["CreatedDate_cmt"],
                            id_cmt_parent   = like_cmt_chill["ID_COMMENT_PARENT"],
                            //Dan_Nhan = h["ID_DANNHAN"],
                            UpdatedDate_cmt = like_cmt_chill["UpdatedDate_cmt"],
                            UpdatedBy_cmt   = like_cmt_chill["UpdatedBy_cmt"],
                            AllowEdit       = like_cmt_chill["CreatedBy_cmt"],

                            User_comment_child = from user in dt_user.AsEnumerable()
                                                 where user["ID_USER"].ToString().Equals(like_cmt_chill["CreatedBy_cmt"].ToString())
                                                 select new
                            {
                                ID_user  = user["ID_USER"],
                                Username = user["UserName"],
                                ID_NV    = user["IDNV"],
                                hinhanh  = user["AVATAR"],
                                avatar   = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]),
                            },

                            Like_child = (
                                from lr in dt_comment_like_user.AsEnumerable()
                                where lr["ID_COMMENT"].Equals(like_cmt_chill["ID_COMMENT"]) && lr["CREATE_BY"].Equals(loginData.Id)
                                //&& lr["CreatedBy"].Equals(r["CreatedBy"]))
                                select new
                            {
                                CreateBy = lr["CREATE_BY"],
                                ID_like = lr["ID_LIKE"],
                                title = lr["title"],
                                icon = lr["LINK_ICON"],
                                //icon_app = lr["ICON_APP"],
                            }).FirstOrDefault(),
                            Like_Comment_child = from like_cmt in dt_like_comment.AsEnumerable()
                                                 where like_cmt["ID_COMMENT"].ToString().Equals(like_cmt_chill["ID_COMMENT"].ToString())
                                                 select new
                            {
                                ID_like = like_cmt["ID_LIKE"],
                                title   = like_cmt["title"],
                                icon    = like_cmt["LINK_ICON"],
                                //icon_app = like_cmt["ICON_APP"],
                                tong = like_cmt["tong"],
                            },
                        },
                    },
                };



                //CustemerID = loginData.IDKHDPS,
                return(JsonResultCommon.ThanhCong(data, pageModel));
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
Пример #6
0
        public object getDSBaiDangFlowTrangCaNhan(int id, [FromQuery] QueryParams_New query)

        {
            //string Token = lc.GetHeader(Request);
            //LoginData loginData = lc._GetInfoUser(Token);
            //if (loginData == null)
            //    return JsonResultCommon.DangNhap();

            PageModel     pageModel   = new PageModel();
            string        sql         = "";
            string        sql_baidang = "";
            SqlConditions Conds       = new SqlConditions();


            DataTable dt_baidang = new DataTable();
            DataTable dt_user    = new DataTable();

            DataTable dt_like_baidang = new DataTable();

            DataTable dt_like_comment = new DataTable();
            DataTable dt_comment      = new DataTable();
            DataTable dt_user_comment = new DataTable();
            DataTable dt                = new DataTable();
            DataTable dt_like           = new DataTable();
            DataTable dt_comment_parent = new DataTable();
            DataTable dt_icon           = new DataTable();

            DataTable dt_baidang_like_user = new DataTable();

            DataTable dt_comment_like_user = new DataTable();
            DataTable dt_baidangcanhan     = new DataTable();
            DataTable dt_kt    = new DataTable();
            DataTable dt_group = new DataTable();

            DataRow[] dr;
            // DataRow[] dr;



            try
            {
                sql_baidang = @" select ID_BAIDANG,CreatedDate from TBL_BAIDANG where CreatedBy=" + id + "UNION select ID_BAIDANG,CreatedDate from TBL_BaiDang_TRANGCANHAN where ID_USER="******" ORDER BY CreatedDate DESC";

                sql = @"
  select ID_BAIDANG,ID_LOAIBAIDANG,TIEUDE,NOIDUNG_BAIDANG,TYPEPOST,CreatedDate,CreatedBy,UpdateDate,UpdateBy,ID_KHENTHUONG,ID_GROUP from TBL_BAIDANG
                ORDER BY ID_BAIDANG DESC";


                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    //dt = cnn.CreateDataTable(sql, Conds);

                    dt_baidangcanhan = cnn.CreateDataTable(sql_baidang, Conds);
                    Thread.Sleep(500);
                    dt         = cnn.CreateDataTable(sql);
                    dt_comment = cnn.CreateDataTable(@"select * from TBL_COMMENT");
                    dt_like    = cnn.CreateDataTable(@"select * from TBL_COMMENT");
                    //dt_user_baidang = cnn.CreateDataTable(@"select * from TBL_USER");
                    dt_user = cnn.CreateDataTable(@"select * from TBL_Account");

                    dt_like_baidang = cnn.CreateDataTable(@" 
   select l.ID_LIKE,likebd.ID_BAIDANG, l.title,count(likebd.ID_LIKE) as tong ,l.LINK_ICON from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where
 l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0  group by l.title,likebd.ID_BAIDANG,l.ID_LIKE,l.LINK_ICON
");
                    dt_user_comment = cnn.CreateDataTable(@"select * from TBL_Account");
                    dt_like_comment = cnn.CreateDataTable(@" select top 3 l.ID_LIKE,cmtlike.ID_COMMENT, l.title,count(cmtlike.ID_LIKE) as tong,l.LINK_ICON  from TBL_COMMENT_LIKE as cmtlike ,TBL_LIKE as l where
 l.ID_LIKE=cmtlike.ID_LIKE and cmtlike.COL_DISABLED=0
 group by l.title,cmtlike.ID_COMMENT,l.ID_LIKE,l.LINK_ICON order by tong desc   
");

                    dt_icon = cnn.CreateDataTable("select * from TBL_LIKE");

                    dt_baidang_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,likebd.ID_BAIDANG, l.title,l.LINK_ICON,likebd.CREATE_BY,likebd.COL_DISABLED from TBL_BAIDANG_LIKE as likebd ,TBL_LIKE as l where
 l.ID_LIKE=likebd.ID_LIKE and likebd.COL_DISABLED=0
  
");

                    dt_comment_like_user = cnn.CreateDataTable(@" select l.ID_LIKE,like_cmt.ID_COMMENT, l.title,l.LINK_ICON,like_cmt.CREATE_BY  from TBL_COMMENT_LIKE as like_cmt ,TBL_LIKE as l where
 l.ID_LIKE=like_cmt.ID_LIKE and like_cmt.COL_DISABLED=0
");

                    dt_comment_parent = cnn.CreateDataTable(@"  SELECT *
FROM TBL_COMMENT
WHERE ID_COMMENT_PARENT !=0");
                    dt_kt             = cnn.CreateDataTable(@"

select * from TBL_KHENTHUONG
");

                    dt_group = cnn.CreateDataTable(@"

select ID_GROUP,TEN_GROUP from TBL_GROUP 
");
                }


                int total = dt_baidangcanhan.Rows.Count;


                pageModel.TotalCount = total;
                pageModel.AllPage    = (int)Math.Ceiling(total / (decimal)query.record);
                pageModel.Size       = query.record;
                pageModel.Page       = query.page;
                if (query.more)
                {
                    query.page   = 1;
                    query.record = pageModel.TotalCount;
                }
                if (query.page <= pageModel.AllPage)
                {
                    dt_baidangcanhan = dt_baidangcanhan.AsEnumerable().Skip((query.page - 1) * query.record).Take(query.record).CopyToDataTable();
                }
                else
                {
                    return(JsonResultCommon.NotData());
                }


                //lay anh usser


                //anh usser cmt



                var data = from p in dt_baidangcanhan.AsEnumerable()
                           select new
                {
                    Id_baidang_canhan = p["ID_BAIDANG"],


                    DataBaiDang = from r in dt.AsEnumerable()
                                  where r["ID_BAIDANG"].ToString().Equals(p["ID_BAIDANG"].ToString())
                                  select new
                    {
                        Id_BaiDang     = r["ID_BAIDANG"],
                        Id_LoaiBaiDang = r["ID_LOAIBAIDANG"],
                        title          = r["TIEUDE"],
                        NoiDung        = r["NOIDUNG_BAIDANG"],
                        CreatedDate    = r["CreatedDate"],
                        CreatedBy      = r["CreatedBy"],
                        // Id_Group = r["ID_GROUP"],
                        hinhanh = r["TYPEPOST"],
                        image   = LiteController.genLinkImage_Post(_config.LinkAPI, r["TYPEPOST"]),
                        //UpdateDate = r["UpdateDate"],
                        //UpdateBy = r["UpdateBy"],
                        ///   id_khenthuong = r["ID_KHENTHUONG"]



                        AllowEdit = r["CreatedBy"],

                        // bai dang duoc like
                        Group = from g in dt_group.AsEnumerable()
                                where r["ID_GROUP"].Equals(g["ID_GROUP"])
                                select new
                        {
                            id_group  = g["ID_GROUP"],
                            ten_group = g["TEN_GROUP"],
                            //icon = g["LINK_ICON"],
                        },


                        KhenThuong = from kt in dt_kt.AsEnumerable()
                                     where r["ID_KHENTHUONG"].Equals(kt["ID_KHENTHUONG"])
                                     select new
                        {
                            id_khenthuong = kt["ID_KHENTHUONG"],
                            tieude_kt     = kt["TIEUDE"],
                            icon          = kt["LINK_ICON"],
                        },


                        Like = dt_baidang_like_user == null ? null : (

                            from lr in dt_baidang_like_user.AsEnumerable()
                            where lr["ID_BAIDANG"].Equals(r["ID_BAIDANG"]) && lr["CREATE_BY"].Equals(id)
                            //&& lr["CreatedBy"].Equals(r["CreatedBy"]))
                            select new
                        {
                            CreateBy = lr["CREATE_BY"],
                            ID_like = lr["ID_LIKE"],
                            title = lr["title"],
                            icon = lr["LINK_ICON"],
                            //icon_app = lr["ICON_APP"]
                        }).FirstOrDefault(),

                        //Like = ttt,
                        Like_BaiDang = from like_bd in dt_like_baidang.AsEnumerable()
                                       where like_bd["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString())
                                       select new
                        {
                            ID_like = like_bd["ID_LIKE"],
                            title   = like_bd["title"],
                            icon    = like_bd["LINK_ICON"],
                            //icon_app= like_bd["ICON_APP"],
                            tong = like_bd["tong"],
                        },
                        User_DangBai = from user in dt_user.AsEnumerable()
                                       where user["ID_USER"].ToString().Equals(r["CreatedBy"].ToString())
                                       select new
                        {
                            ID_user  = user["ID_USER"],
                            Username = user["UserName"],
                            ID_NV    = user["IDNV"],

                            hinhanh = user["AVATAR"],
                            avatar  = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]),
                        },
                        // Trong bai dang co nhung commet nao
                        Coment = from h in dt_comment.AsEnumerable()
                                 where h["ID_BAIDANG"].ToString().Equals(r["ID_BAIDANG"].ToString())
                                 select new
                        {
                            id_cmt     = h["ID_COMMENT"],
                            Id_BaiDang = h["ID_BAIDANG"],

                            NoiDung_cmt = h["NOIDUNG_COMMENT"],
                            typepost    = h["TYPEPOST"],
                            //  hinh_cmt = $"{link}/UploadedFiles/{h["TYPEPOST"]}",
                            CreatedBy     = h["CreatedBy_cmt"],
                            CreatedDate   = h["CreatedDate_cmt"],
                            id_cmt_parent = h["ID_COMMENT_PARENT"],
                            //Dan_Nhan = h["ID_DANNHAN"],
                            //UpdatedDate = h["UpdatedDate_cmt"],
                            //UpdatedBy = h["UpdatedBy_cmt"],
                            AllowEdit = h["CreatedBy_cmt"],

                            User_comment = from user in dt_user.AsEnumerable()
                                           where user["ID_USER"].ToString().Equals(h["CreatedBy_cmt"].ToString())
                                           select new
                            {
                                ID_user  = user["ID_USER"],
                                Username = user["UserName"],
                                ID_NV    = user["IDNV"],
                                hinhanh  = user["AVATAR"],
                                avatar   = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]),
                            },
                            Like = (
                                from lr in dt_comment_like_user.AsEnumerable()
                                where lr["ID_COMMENT"].Equals(h["ID_COMMENT"]) && lr["CREATE_BY"].Equals(id
                                                                                                         )
                                //&& lr["CreatedBy"].Equals(r["CreatedBy"]))
                                select new
                            {
                                CreateBy = lr["CREATE_BY"],
                                ID_like = lr["ID_LIKE"],
                                title = lr["title"],
                                icon = lr["LINK_ICON"],
                                //icon_app = lr["ICON_APP"],
                            }).FirstOrDefault(),
                            Like_Comment = from like_cmt in dt_like_comment.AsEnumerable()
                                           where like_cmt["ID_COMMENT"].ToString().Equals(h["ID_COMMENT"].ToString())
                                           select new
                            {
                                ID_like = like_cmt["ID_LIKE"],
                                title   = like_cmt["title"],
                                icon    = like_cmt["LINK_ICON"],
                                //icon_app = like_cmt["ICON_APP"],
                                tong = like_cmt["tong"],
                            },

                            Comment_child = from like_cmt_chill in dt_comment_parent.AsEnumerable()
                                            where like_cmt_chill["ID_COMMENT_PARENT"].ToString().Equals(h["ID_COMMENT"].ToString())
                                            select new
                            {
                                id_cmt = like_cmt_chill["ID_COMMENT"],
                                //Id_BaiDang = like_cmt_chill["ID_BAIDANG"],

                                NoiDung_cmt = like_cmt_chill["NOIDUNG_COMMENT"],
                                TypePost    = like_cmt_chill["TYPEPOST"],
                                //  hinh_cmt = $"{link}/UploadedFiles/{like_cmt_chill["TYPEPOST"]}",
                                CreatedBy     = like_cmt_chill["CreatedBy_cmt"],
                                CreatedDate   = like_cmt_chill["CreatedDate_cmt"],
                                id_cmt_parent = like_cmt_chill["ID_COMMENT_PARENT"],
                                //Dan_Nhan = h["ID_DANNHAN"],
                                //UpdatedDate_cmt = like_cmt_chill["UpdatedDate_cmt"],
                                //UpdatedBy_cmt = like_cmt_chill["UpdatedBy_cmt"],
                                AllowEdit = like_cmt_chill["CreatedBy_cmt"],

                                User_comment_child = from user in dt_user.AsEnumerable()
                                                     where user["ID_USER"].ToString().Equals(like_cmt_chill["CreatedBy_cmt"].ToString())
                                                     select new
                                {
                                    ID_user  = user["ID_USER"],
                                    Username = user["UserName"],
                                    ID_NV    = user["IDNV"],
                                    hinhanh  = user["AVATAR"],
                                    avatar   = LiteController.genLinkAvatar(_config.LinkAPI, user["AVATAR"]),
                                },

                                Like_child = (
                                    from lr in dt_comment_like_user.AsEnumerable()
                                    where lr["ID_COMMENT"].Equals(like_cmt_chill["ID_COMMENT"]) && lr["CREATE_BY"].Equals(id
                                                                                                                          )
                                    //&& lr["CreatedBy"].Equals(r["CreatedBy"]))
                                    select new
                                {
                                    CreateBy = lr["CREATE_BY"],
                                    ID_like = lr["ID_LIKE"],
                                    title = lr["title"],
                                    icon = lr["LINK_ICON"],
                                    //icon_app = lr["ICON_APP"],
                                }).FirstOrDefault(),
                                Like_Comment_child = from like_cmt in dt_like_comment.AsEnumerable()
                                                     where like_cmt["ID_COMMENT"].ToString().Equals(like_cmt_chill["ID_COMMENT"].ToString())
                                                     select new
                                {
                                    ID_like = like_cmt["ID_LIKE"],
                                    title   = like_cmt["title"],
                                    icon    = like_cmt["LINK_ICON"],
                                },
                            },
                        },
                    },
                };



                //CustemerID = loginData.IDKHDPS,
                //  page = pageModel;
                return(JsonResultCommon.ThanhCong(data, pageModel));

                // ; ; ;
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
Пример #7
0
        public object GetDataEDit(int id_baidang)
        {
            {
                int           status = 0;
                string        Id     = "";
                string        Token  = "";
                SqlConditions Conds  = new SqlConditions();
                DataTable     dt     = new DataTable();
                DataRow[]     dr;
                bool          Visible  = true;
                List <object> rs       = new List <object>();
                string        title    = "";
                DataTable     dt_kt    = new DataTable();
                DataTable     dt_token = new DataTable();
                try
                {
                    //Conds.Add("email", Email);
                    //Conds.Add("password", Pass);
                    using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                    {
                        dt_kt = cnn.CreateDataTable(@"

select * from TBL_KHENTHUONG
");

                        dt = cnn.CreateDataTable(@"

   select * from TBL_BAIDANG where ID_BAIDANG=" + id_baidang, Conds);
                        //dt_token = cnn.CreateDataTable("select * from LoginSection where Token = @token and Id = @Id_nv", Conds);
                    }

                    var data = from r in dt.AsEnumerable()
                               select new
                    {
                        Id_BaiDang     = r["ID_BAIDANG"],
                        Id_LoaiBaiDang = r["ID_LOAIBAIDANG"],
                        title          = r["TIEUDE"],
                        NoiDung        = r["NOIDUNG_BAIDANG"],
                        CreatedDate    = r["CreatedDate"],
                        CreatedBy      = r["CreatedBy"],
                        Id_Group       = r["ID_GROUP"],
                        hinhanh        = r["TYPEPOST"],
                        image          = LiteController.genLinkImage_Post(_config.LinkAPI, r["TYPEPOST"]),
                        UpdateDate     = r["UpdateDate"],
                        UpdateBy       = r["UpdateBy"],
                        id_khenthuong  = r["ID_KHENTHUONG"],
                        AllowEdit      = r["CreatedBy"],

                        KhenThuong = from kt in dt_kt.AsEnumerable()
                                     where r["ID_KHENTHUONG"].Equals(kt["ID_KHENTHUONG"])
                                     select new
                        {
                            id_khenthuong = kt["ID_KHENTHUONG"],
                            tieude_kt     = kt["TIEUDE"],
                            icon          = kt["LINK_ICON"],
                        },
                    };
                    return(JsonResultCommon.ThanhCong(data));
                }
                catch (Exception ex)
                {
                    return(JsonResultCommon.Exception(ex));
                }
            }
        }