public IHttpActionResult DanhSach(string maSinhVien, string matKhau, int soTrang, int soDong) { if (string.IsNullOrEmpty(maSinhVien) || string.IsNullOrEmpty(matKhau) || soTrang < 1 || soDong < 1) { return(BadRequest("Tham số truyền vào không hợp lệ !")); } var current = SinhVienDao.TonTaiSinhVien(maSinhVien, matKhau); if (current == false) { return(BadRequest("Thong tin sinh vien khong hop le !")); } var soDongTong = ThongBaoDao.GetSoDong(); var temp = soDongTong % soDong; var subTongSoTrang = soDongTong / soDong; var tongSoTrang = temp == 0 ? subTongSoTrang : subTongSoTrang + 1; if (soTrang > tongSoTrang) { return(Ok(new List <THONGBAO>())); } var listThongBao = ThongBaoDao.GetThongBaoTheoSoTrang(soTrang, soDong); return(Ok(listThongBao)); }
// GET: ThongBaoClient public ActionResult Index() { var dethilist = new DeThiDao().ListDeThiMoi(); ViewBag.dethilist = dethilist; var thongbao = new ThongBaoDao(); ViewBag.ListThongBao = thongbao.toList(); return(View()); }
// GET: Admin/ThongBao/Delete/5 public ActionResult Delete(int id) { var ketqua = new ThongBaoDao().XoaThongBao(id); if (!ketqua) { ModelState.AddModelError("", "loi"); } else { return(RedirectToAction("Index")); } return(View("Index")); }
public ActionResult Index() { var dethilist = new DeThiDao().ListDeThiMoi(); ViewBag.dethilist = dethilist; var dao = new ShowGiaoDienChinhDao(); ViewBag.MenuChinh = dao.ListCapThi(); ViewBag.MenuCon = dao.ListMonThi(); var thongbao = new ThongBaoDao(); ViewBag.ListThongBao = thongbao.toList(); var socau = new SoCauDao(); ViewBag.socau = socau.toList(); var thoigian = new ThoiGianDao(); ViewBag.thoigian = thoigian.toList(); var chuyennganh = new ChuyenNganhDao(); ViewBag.chuyennganh = chuyennganh.toList(); var dethi = new DeThiDao(); ViewBag.dethi = dethi.toList(); var dao0 = new MucDoDao(); ViewBag.MucDoID = new SelectList(dao0.toList(), "IDMUCDO", "TENMUCDO"); var dao1 = new MonThiDao(); ViewBag.MonThiID = new SelectList(dao1.toList(), "IDMON", "TENMON"); var dao2 = new ThoiGianDao(); ViewBag.ThoiGianID = new SelectList(dao2.toList(), "IDTHOIGIAN", "THOIGIAN1"); var dao3 = new SoCauDao(); ViewBag.SoCauID = new SelectList(dao3.toList(), "IDSOCAU", "SOCAU1"); var dao4 = new CapThiDao(); ViewBag.CapThiID = new SelectList(dao4.toList(), "IDCAPTHI", "TENCAPTHI"); var tintuc = new TinTucDao(); ViewBag.tintuc = tintuc.listtintucsapxep(); ViewBag.tintuctop = tintuc.tintuctop1(); return(View()); }
public ActionResult Create(THONGBAO model, FormCollection collection) { try { model.TRANGTHAI = true; model.NGAYDANG = DateTime.Now; var ketqua = new ThongBaoDao().ThemThongBao(model); if (ketqua) { return(RedirectToAction("Index")); } } catch { ModelState.AddModelError("", "Không thể tạo mới thông báo"); return(View()); } return(View("Index")); }
public ActionResult Edit(THONGBAO model, FormCollection collection) { try { // TODO: Add update logic here var ketqua = new ThongBaoDao().SuaThongBao(model); if (ketqua == 0) { ModelState.AddModelError("", "loi"); } else { return(RedirectToAction("Index")); } } catch { return(View()); } return(View("Index")); }
public ActionResult DemoPostNews(FormCollection form) { string tieuDe = HttpUtility.HtmlEncode(form["txtTieuDe"]); string noiDung = HttpUtility.HtmlEncode(form["txtNoiDung"]); DateTime thoiGianDang = DateTime.Now; // Them vao db THONGBAO thongBao = new THONGBAO() { MaThongBao = 1, TieuDe = tieuDe, NoiDung = noiDung, ThoiGianDang = thoiGianDang }; DemoKetQua demo = new DemoKetQua(); try { ThongBaoDao.AddThongBao(thongBao); thongBao.MaThongBao = ThongBaoDao.GetMaxId(); // Thong bao den client app FCMController fcm = new FCMController(); string message = fcm.CreateNewsNotification(thongBao); string response = fcm.SendMessage(message); // Hien thi ket qua thanh cong demo.KetQua = "Them thanh cong !!!"; demo.PhanHoi = response; demo.TinGuiDi = message; } catch (Exception ex) { // hien thi loi demo.PhanHoi = ex.Message + ex.StackTrace; } return(RedirectToAction("DemoPostNews", "Demo", demo)); }
protected void btnGui_Click(object sender, EventArgs e) { string tieuDe = HttpUtility.HtmlEncode(txtTieuDe.Text); string noiDung = HttpUtility.HtmlEncode(txtNoiDung.Text); DateTime thoiGianDang = DateTime.Now; // Them vao db THONGBAO thongBao = new THONGBAO() { MaThongBao = 1, TieuDe = tieuDe, NoiDung = noiDung, ThoiGianDang = thoiGianDang }; try { ThongBaoDao.AddThongBao(thongBao); thongBao.MaThongBao = ThongBaoDao.GetMaxId(); // Thong bao den client app FCMController fcm = new FCMController(); string message = fcm.CreateNewsNotification(thongBao); string response = fcm.SendMessage(message); // Hien thi ket qua thanh cong lblKetQua.Text = "Them thanh cong !!!"; lblKetQua.CssClass = "text-success"; lblLoi.Text = response; lblTinGuiDi.Text = message; } catch (Exception ex) { // hien thi loi lblLoi.Text = ex.Message + ex.StackTrace; return; } }
public IHttpActionResult ChiTiet(string maSinhVien, string matKhau, int id) { if (string.IsNullOrEmpty(maSinhVien) || string.IsNullOrEmpty(matKhau)) { return(BadRequest("Tham số truyền vào không hợp lệ !")); } var sv = SinhVienDao.TonTaiSinhVien(maSinhVien, matKhau); if (sv == false) { return(BadRequest("Thong tin sinh vien khong hop le !")); } var tb = ThongBaoDao.GetThongBaoTheoId(id); if (tb == null) { return(BadRequest("Mã thông báo không tồn tại !")); } return(Ok(tb)); }