public ActionResult Delete(int id=0) { //check if (!this._nhanvien_permission.Contains("phanhoi_delete")) { return this._fail_permission("phanhoi_delete"); } PhanHoiController ctr = new PhanHoiController(); if (!ctr.is_exist(id)) { return RedirectToAction("Index", "AdminPhanHois"); } //delete ctr.delete(id); return RedirectToAction("Index","AdminPhanHois"); }
public ActionResult Index(int page=1, int phanhoi_id=0) { //check if (!this._nhanvien_permission.Contains("phanhoi_view")) { return this._fail_permission("phanhoi_view"); } PhanHoiController ctr = new PhanHoiController(); //pagination int max_item_per_page = TextLibrary.ToInt(this.timkiem_phanhoi["max_item_per_page"]); Pagination pg = new Pagination(); pg.set_current_page(page); pg.set_max_item_per_page(max_item_per_page); pg.set_total_item( ctr.timkiem_count( timkiem_phanhoi["id"], timkiem_phanhoi["tieude"], timkiem_phanhoi["noidung"], timkiem_phanhoi["nguoigui_ten"], timkiem_phanhoi["nguoigui_email"] ) ); pg.update(); //Chọn danh sách để hiển thị theo cookies tìm kiếm ViewBag.PhanHoi_List = ctr.timkiem( timkiem_phanhoi["id"], timkiem_phanhoi["tieude"], timkiem_phanhoi["noidung"], timkiem_phanhoi["nguoigui_ten"], timkiem_phanhoi["nguoigui_email"], "", "id", true, pg.start_point, pg.max_item_per_page ); //set search cookies ViewBag.timkiem_phanhoi = this.timkiem_phanhoi; ViewBag.phanhoi = ctr.is_exist(phanhoi_id) ? ctr.get_by_id(phanhoi_id) : new PhanHoi(); ViewBag.Title += " - Quản lý"; ViewBag.State = TempData["state"] == null ? new List<string>() : (List<string>)TempData["state"]; ViewBag.pagination = pg; return View(); }
public ActionResult Reply_Submit() { //check if (!this._nhanvien_permission.Contains("phanhoi_edit")) { return this._fail_permission("phanhoi_edit"); } //set nguoi xu ly phan hoi int phanhoi_id = TextLibrary.ToInt(Request["phanhoi_id"]); // PhanHoiController ctr = new PhanHoiController(); PhanHoi obj = ctr.get_by_id(phanhoi_id); if (obj != null) { obj.nhanvien = ctr._db.ds_nhanvien.Where(x => x.id == this._nhanvien.id).FirstOrDefault(); //lưu ctr._db.SaveChanges(); } //get value string email = TextLibrary.ToString(Request["email"]); string tieude = TextLibrary.ToString(Request["tieude"]); string noidung = TextLibrary.ToString(Request.Unvalidated["noidung"]); //send email GMailLibrary gmail = new GMailLibrary(); gmail.receive_email = email; gmail.receive_title = tieude; gmail.receive_html = noidung; try { gmail.Send(); } catch (Exception) { return RedirectToAction("Index", "AdminPhanHois"); } TempData["state"] = (new string[] { "send_ok" }).ToList<string>(); return RedirectToAction("Index", "AdminPhanHois"); }
public ActionResult Submit() { PhanHoiController ctr = new PhanHoiController(); PhanHoi obj = new PhanHoi(); //get post value string tendaydu = TextLibrary.ToString(Request["front_contact_author"]); string sdt = TextLibrary.ToString(Request["front_contact_phone"]); string email = TextLibrary.ToString(Request["front_contact_email"]); string tieude = TextLibrary.ToString(Request["front_contact_tieude"]); string noidung = TextLibrary.ToString(Request["front_contact_text"]); string captcha = TextLibrary.ToString(Request["front_contact_captcha"]); //pass to obj if (this._khachhang != null) { obj.khachhang = ctr._db.ds_khachhang.Where(x => x.id == this._khachhang.id).FirstOrDefault(); } else { obj.nguoigui_email = email; obj.nguoigui_sdt = sdt; obj.nguoigui_ten = tendaydu; } obj.tieude = tieude; obj.noidung = noidung; //validate List<string> validate = ctr.validate(obj); //xét captcha if (!this.get_captcha_string().ToLower().Equals(captcha.ToLower())) { validate.Add("captcha_fail"); } //Check ok if (validate.Count == 0) { ctr.add(obj); validate.Add("success"); } ViewBag.State = validate; ViewBag.phanhoi = obj; return View("Index"); }