public JsonResult GetAllData(int rows, int page) { ChucVuServices service = new ChucVuServices(); List<ChucVuEntity> listChucVuEntity = new List<ChucVuEntity>(); try { listChucVuEntity = service.GetAll(); return Json(PaginationHelper<ChucVuEntity>.Execute(listChucVuEntity, page, rows), JsonRequestBehavior.AllowGet); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } return Json(null); }
/// only return json to client public ActionResult Create(ChucVuEntity chucVuEntity) { ChucVuServices service = new ChucVuServices(); if (chucVuEntity == null) { RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"); return Json(JsonConvert.SerializeObject(ViewData)); } if (service.Create(chucVuEntity)) { return Json(RenderResult.RequestCompleted(ViewData, "Thêm chức vụ thành công")); } else { return Json(RenderResult.RequestCompleted(ViewData, "Lỗi khi thêm chức vụ")); } }
// GET: ChucVuEntity public ActionResult Index() { ChucVuServices service = new ChucVuServices(); List<ChucVuEntity> listChucVuEntity = new List<ChucVuEntity>(); string result = null; try { listChucVuEntity = service.GetAll(); result = JsonConvert.SerializeObject(listChucVuEntity); RenderResult.RequestCompleted(ViewData, result); } catch (Exception e) { System.Console.WriteLine(e.ToString()); RenderResult.RequestError(ViewData, "Lỗi hệ thống"); } return View(); }
public ActionResult Edit(ChucVuEntity chucVuEntity) { ChucVuServices service = new ChucVuServices(); if (chucVuEntity == null) { return Json(RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"), JsonRequestBehavior.AllowGet); } try { if (service.Update(chucVuEntity)) 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")); } }
public JsonResult GetMaQuyDinh() { ChucVuServices service = new ChucVuServices(); try { return Json(RenderResult.RequestCompleted(ViewData, GenKey.GenIncrementKey("CV", 3, service.GetAll().Count)), JsonRequestBehavior.AllowGet); } catch (Exception e) { return Json(RenderResult.RequestError(ViewData, "Lỗi xảy ra"), JsonRequestBehavior.AllowGet); } }
public ActionResult Delete(ChucVuEntity chucVuEntity) { ChucVuServices service = new ChucVuServices(); try { if (service.Delete(chucVuEntity)) 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) { ChucVuServices service = new ChucVuServices(); if (id == null) return Json(RenderResult.RequestError(ViewData, "Đối số không hợp lệ")); try { List<int> ids = StringUtility.SplitIdEntity(id); 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")); } }