public JsonResult GetAllData(int rows, int page) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); List<TrinhDoHocVanEntity> listTrinhDoHocVan = new List<TrinhDoHocVanEntity>(); try { listTrinhDoHocVan = service.GetAll(); return Json(PaginationHelper<TrinhDoHocVanEntity>.Execute(listTrinhDoHocVan, page, rows), JsonRequestBehavior.AllowGet); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } return Json(null); }
public JsonResult GetAllDataWithoutPagination() { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); List<TrinhDoHocVanEntity> listTrinhDoHocVan = new List<TrinhDoHocVanEntity>(); string result = null; try { listTrinhDoHocVan = service.GetAll(); result = JsonConvert.SerializeObject(listTrinhDoHocVan); return Json(RenderResult.RequestCompleted(ViewData, result), JsonRequestBehavior.AllowGet); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } return Json(null); }
/// only return json to client public ActionResult Create(TrinhDoHocVanEntity trinhDoHocVan) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); if (trinhDoHocVan == null) { RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"); return Json(JsonConvert.SerializeObject(ViewData)); } if (service.Create(trinhDoHocVan)) { return Json(RenderResult.RequestCompleted(ViewData, "Thêm dân tộc thành công")); } else { return Json(RenderResult.RequestCompleted(ViewData, "Lỗi khi thêm dân tộc")); } }
// GET: trinhDoHocVan public ActionResult Index() { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); List<TrinhDoHocVanEntity> listtrinhDoHocVan = new List<TrinhDoHocVanEntity>(); string result = null; try { listtrinhDoHocVan = service.GetAll(); result = JsonConvert.SerializeObject(listtrinhDoHocVan); RenderResult.RequestCompleted(ViewData, result); } catch (Exception e) { System.Console.WriteLine(e.ToString()); RenderResult.RequestError(ViewData, "Lỗi hệ thống"); } return View(); }
public JsonResult GetMaQuyDinh() { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); try { return Json(RenderResult.RequestCompleted(ViewData, GenKey.GenIncrementKey("TDHV", 3, service.GetAll().Count)), JsonRequestBehavior.AllowGet); } catch (Exception e) { System.Console.WriteLine(e.ToString()); return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra"), JsonRequestBehavior.AllowGet); } }
public ActionResult Delete(TrinhDoHocVanEntity trinhDoHocVan) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); try { if (service.Delete(trinhDoHocVan)) return Json(RenderResult.RequestCompleted(ViewData, "Xóa thành công")); return Json(RenderResult.RequestCompleted(ViewData, "Xóa không thành công")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra")); } }
public ActionResult DeleteWithID(string id) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); if (id == null) return Json(RenderResult.RequestError(ViewData, "Đối số không hợp lệ")); List<int> ids = StringUtility.SplitIdEntity(id); try { for (int i = 0; i < ids.Count; ++i) { service.Delete(ids[i]); } return Json(RenderResult.RequestCompleted(ViewData, "Xóa thành công")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra")); } }
public ActionResult Edit(TrinhDoHocVanEntity trinhDoHocVan) { TrinhDoHocVanServices service = new TrinhDoHocVanServices(); if (trinhDoHocVan == null) { return Json(RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"), JsonRequestBehavior.AllowGet); } try { if (service.Update(trinhDoHocVan)) return Json(RenderResult.RequestCompleted(ViewData, "Chỉnh sửa thành công")); return Json(RenderResult.RequestCompleted(ViewData, "Chỉnh sửa không thành công")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra")); } }