public static List <TinNhan> GetTinNhanNhanDaXoa(string maSinhVien) { using (var db = new UMS_HUSCEntities()) { var list = new List <TinNhan>(); var maTaiKhoan = SinhVienDao.GetMaTaiKhoan(maSinhVien); var tinDaNhan = db.VTinNhanDaNhans.Where(n => n.MaNguoiNhan == maTaiKhoan && n.TrangThai == TINNHAN_TAM_XOA).ToList(); foreach (var item in tinDaNhan) { string temp = HttpUtility.HtmlDecode(item.NoiDung); item.NoiDung = temp.Replace("\r\n", "") .Replace("style=\"", "style='") .Replace("href=\"", "href='") .Replace("\">", "'>") .Replace(";\"", ";'") .Replace("\"", """); item.TieuDe = HttpUtility.HtmlDecode(item.TieuDe).Replace("\r\n", ""); TinNhan tinNhan = new TinNhan() { MaTinNhan = item.MaTinNhan, MaNguoiGui = item.MaNguoiGui, HoTenNguoiGui = item.HoTenNguoiGui, TieuDe = item.TieuDe, NoiDung = item.NoiDung, ThoiDiemGui = item.ThoiDiemGui, NguoiNhans = GetAllNguoiNhan(item.MaTinNhan) }; list.Add(tinNhan); } return(list.OrderBy(t => t.ThoiDiemGui).ToList()); } }
public static bool RestoreTinNhan(int id, string maSinhVien) { using (var db = new UMS_HUSCEntities()) { var current = db.TINNHANs.FirstOrDefault(t => t.MaTinNhan == id); if (current != null) { var maTaiKhoan = SinhVienDao.GetMaTaiKhoan(maSinhVien); var nguoiGui = db.NGUOIGUIs.FirstOrDefault(n => n.MaNguoiGui == maTaiKhoan && n.MaTinNhan == id); if (nguoiGui != null) // sinh vien nay la nguoi gui tin nhan { nguoiGui.TrangThai = TINNHAN_CHUA_XOA; } else { var nguoiNhan = db.NGUOINHANs.FirstOrDefault(n => n.MaNguoiNhan == maTaiKhoan && n.MaTinNhan == id); if (nguoiNhan != null) { nguoiNhan.TrangThai = TINNHAN_CHUA_XOA; } } db.SaveChanges(); return(true); } return(false); } }
public static long GetTongTinNhanDaNhan(string maSinhVien) { using (UMS_HUSCEntities db = new UMS_HUSCEntities()) { var maTaiKhoan = SinhVienDao.GetMaTaiKhoan(maSinhVien); return(db.VTinNhanDaNhans.Where(t => t.MaNguoiNhan.Equals(maTaiKhoan)).Count()); } }
public static bool UpdateThoiDiemXem(int id, string maSinhVien) { using (var db = new UMS_HUSCEntities()) { var tinNhan = db.TINNHANs.FirstOrDefault(t => t.MaTinNhan == id); if (tinNhan != null) { var maTaiKhoan = SinhVienDao.GetMaTaiKhoan(maSinhVien); var nguoiNhan = db.NGUOINHANs.FirstOrDefault(n => n.MaNguoiNhan == maTaiKhoan && n.MaTinNhan == id); //var nguoiGui = db.NGUOIGUIs.FirstOrDefault(n => n.MaNguoiGui == maTaiKhoan && n.MaTinNhan == id); if (nguoiNhan != null && nguoiNhan.ThoiDiemXem == null) { nguoiNhan.ThoiDiemXem = DateTime.Now; db.SaveChanges(); } return(nguoiNhan != null) /*|| (nguoiGui != null)*/; } return(false); } }