Ejemplo n.º 1
0
 private void preparebaiviets(ref JsonObjectBaiViet bai)
 {
     if (bai.noidung.Length >= 100)
     {
         bai.noidung = bai.noidung.Substring(0, 99);
     }
     bai.loai    = 'q';
     bai.noidung = RemoveHTMLTags(bai.noidung);
 }
Ejemplo n.º 2
0
        public JsonResult getQuestion(int?index, int number = 0)
        {
            JsonObjectBaiViet[] questions = new JsonObjectBaiViet[5];

            int x = 3;

            if (number != 0)
            {
                x = number;
            }

            int skip;

            if (index == null || index == 0)
            {
                skip = 0;
            }
            else
            {
                skip = (int)(x * index);
            }

            questions = db.Questions.OrderByDescending(t => t.Ngaydang).Skip(skip).Take(x).Select(t => new JsonObjectBaiViet()
            {
                id       = t.id,
                tieude   = t.Tieude,
                noidung  = t.Noidung,
                ngaydang = t.Ngaydang.ToString(),
                avatar   = t.AspNetUser.profile_avatar_link
            }).ToArray();

            for (int i = 0; i < questions.Length; i++)
            {
                preparebaiviets(ref questions[i]);
            }
            return(Json(questions, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public JsonResult getNewPost(int?index, int number = 0)
        {
            JsonObjectBaiViet[] baiviets = new JsonObjectBaiViet[5];
            int x = 3;

            if (number != 0)
            {
                x = number;
            }

            int skip;

            if (index == null || index == 0)
            {
                skip = 0;
            }
            else
            {
                skip = (int)(x * index);
            }

            baiviets = db.BaiViets.OrderByDescending(t => t.NgayCapNhat).Skip(skip).Take(x).Select(t => new JsonObjectBaiViet()
            {
                id       = t.ID,
                tieude   = t.TieuDe,
                noidung  = t.NoiDung,
                ngaydang = t.NgayCapNhat.ToString(),
                avatar   = t.linkImage
            }).ToArray();

            for (int i = 0; i < baiviets.Length; i++)
            {
                preparebaiviets(ref baiviets[i]);
            }
            return(Json(baiviets, JsonRequestBehavior.AllowGet));
        }