コード例 #1
0
        public JsonResult GetAllData(int rows, int page)
        {
            NgoaiNguService service = new NgoaiNguService();
            List<NgoaiNguEntity> ngoaingus= new List<NgoaiNguEntity>();

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

            return Json(null);
        }
コード例 #2
0
        /// only return json to client
        public ActionResult Create(NgoaiNguEntity ngoaingu)
        {
            NgoaiNguService service = new NgoaiNguService();

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

            if (service.Create(ngoaingu))
            {
                return Json(RenderResult.RequestCompleted(ViewData, "Thêm ngoại ngữ thành công"));
            }
            else
            {

                return Json(RenderResult.RequestCompleted(ViewData, "Lỗi khi thêm ngoại ngữ"));
            }
        }
コード例 #3
0
        // GET: NgoaiNgu
        public ActionResult Index()
        {
            NgoaiNguService service = new NgoaiNguService();
            List<NgoaiNguEntity> ngoaingus= new List<NgoaiNguEntity>();
            string result = null;

            try
            {
                ngoaingus= service.GetAll();
                result = JsonConvert.SerializeObject(ngoaingus);
                RenderResult.RequestCompleted(ViewData, result);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
                RenderResult.RequestError(ViewData, "Lỗi hệ thống");
            }

            return View();
        }
コード例 #4
0
        public ActionResult Edit(NgoaiNguEntity ngoaingu)
        {
            NgoaiNguService service = new NgoaiNguService();

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

            try
            {
                if (service.Update(ngoaingu))
                    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"));
            }
        }
コード例 #5
0
        public JsonResult GetAllDataWithoutPagination()
        {
            NgoaiNguService service = new NgoaiNguService();
            List<NgoaiNguEntity> entities = new List<NgoaiNguEntity>();
            string result = null;
            try
            {
                entities = service.GetAll();
                result = JsonConvert.SerializeObject(entities);
                return Json(RenderResult.RequestCompleted(ViewData, result), JsonRequestBehavior.AllowGet);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }

            return Json(null);
        }
コード例 #6
0
        public JsonResult GetMaQuyDinh()
        {
            NgoaiNguService service = new NgoaiNguService();

            try
            {
                return Json(RenderResult.RequestCompleted(ViewData, GenKey.GenIncrementKey("NN", 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);
            }
        }
コード例 #7
0
        public ActionResult Delete(NgoaiNguEntity ngoaingu)
        {
            NgoaiNguService service = new NgoaiNguService();

            try
            {
                if (service.Delete(ngoaingu))
                    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"));
            }

        }
コード例 #8
0
        public ActionResult DeleteWithID(string id)
        {
            NgoaiNguService service = new NgoaiNguService();

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

        }
コード例 #9
0
 public JsonResult GetAllIdNgoaiNgu()
 {
     string result = null;
     NgoaiNguService service = new NgoaiNguService();
     List<NgoaiNguEntity> nnServices = new List<NgoaiNguEntity>();
     try
     {
         nnServices = service.GetAll();
         result = JsonConvert.SerializeObject(nnServices);
         return Json(nnServices, JsonRequestBehavior.AllowGet);
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.ToString());
         return Json(null);
     }
 }