public JsonResult GetAllData(int rows, int page)
        {
            ThanhTichServices service = new ThanhTichServices();
            List<ThanhTichEntity> thanhTichs = new List<ThanhTichEntity>();

            try
            {
                thanhTichs = service.GetAll();
                return Json(PaginationHelper<ThanhTichEntity>.Execute(thanhTichs, page, rows), JsonRequestBehavior.AllowGet);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }

            return Json(null);
        }
        // GET: ThanhTich
        public ActionResult Index()
        {
            ThanhTichServices service = new ThanhTichServices();
            List<ThanhTichEntity> thanhTichs = new List<ThanhTichEntity>();
            string result = null;

            try
            {
                thanhTichs = service.GetAll();
                result = JsonConvert.SerializeObject(thanhTichs);
                RenderResult.RequestCompleted(ViewData, result);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
                RenderResult.RequestError(ViewData, "Lỗi hệ thống");
            }
            return View();
        }
        /// only return json to client
        public ActionResult Create(ThanhTichEntity thanhTich)
        {
            ThanhTichServices service = new ThanhTichServices();

            if (thanhTich == null)
            {
                RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ");
                return Json(JsonConvert.SerializeObject(ViewData));
            }

            if (service.Create(thanhTich))
            {
                return Json(RenderResult.RequestCompleted(ViewData, "Thêm thành tích thành công"));
            }
            else
            {

                return Json(RenderResult.RequestCompleted(ViewData, "Lỗi khi thêm thành tích"));
            }
        }
        /// only return json to client
        public ActionResult Edit(ThanhTichEntity thanhTich)
        {
            ThanhTichServices service = new ThanhTichServices();

            if (thanhTich == null)
            {
                return Json(RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ"), JsonRequestBehavior.AllowGet);
            }
            
            try
            {
                if (service.Update(thanhTich))
                    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 GetSo()
        {
            ThanhTichServices service = new ThanhTichServices();

            try
            {
                return Json(RenderResult.RequestCompleted(ViewData, GenKey.GenIncrementKey("TT", 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(ThanhTichEntity thanhTich)
        {
            ThanhTichServices service = new ThanhTichServices();

            try
            {
                if (service.Delete(thanhTich))
                    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)
        {
            ThanhTichServices service = new ThanhTichServices();

            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"));
            }

        }