Beispiel #1
0
        public JsonResult SaveItem(LOAITAILIEU_THUOCTINH ThuocTinh)
        {
            if (ThuocTinh.DANHMUC_ID == 0)
            {
                return(Json(new { Type = "ERROR", Message = "Bạn chưa chọn loại tài liệu cho thuộc tính" }, JsonRequestBehavior.AllowGet));
            }
            DM_DANHMUC_DATABusiness = Get <DM_DANHMUC_DATABusiness>();
            DM_DANHMUC_DATA DanhMuc = DM_DANHMUC_DATABusiness.Find(ThuocTinh.DANHMUC_ID);

            if (DanhMuc == null)
            {
                return(Json(new { Type = "ERROR", Message = "Không tìm thấy loại tài liệu được chọn" }, JsonRequestBehavior.AllowGet));
            }
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            if (ThuocTinh.ID > 0)
            {
                #region Cập nhật thuộc tính
                var result = LOAITAILIEU_THUOCTINHBusiness.Find(ThuocTinh.ID);
                if (result == null)
                {
                    return(Json(new { Type = "ERROR", Message = "Không tìm thấy thuộc tính cần cập nhật" }, JsonRequestBehavior.AllowGet));
                }
                result.DANHMUC_ID    = ThuocTinh.DANHMUC_ID;
                result.MOTA          = ThuocTinh.MOTA;
                result.TEN_THUOCTINH = ThuocTinh.TEN_THUOCTINH;
                result.TRANGTHAI     = ThuocTinh.TRANGTHAI;
                LOAITAILIEU_THUOCTINHBusiness.Save(result);
                return(Json(new { Type = "SUCCESS", Message = "Cập nhật thuộc tính thành công" }, JsonRequestBehavior.AllowGet));

                #endregion
            }
            else
            {
                #region Thêm mới thuộc tính
                LOAITAILIEU_THUOCTINHBusiness.Save(ThuocTinh);
                #endregion
            }
            return(Json(new { Type = "SUCCESS", Message = "Thêm mới thuộc tính thành công" }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public JsonResult Delete(long id)
        {
            LOAITAILIEU_THUOCTINHBusiness = Get <LOAITAILIEU_THUOCTINHBusiness>();
            LOAITAILIEU_THUOCTINH ThuocTinh = LOAITAILIEU_THUOCTINHBusiness.Find(id);

            if (ThuocTinh == null)
            {
                return(Json(new { Type = "ERROR", Message = "Không tìm thấy thuộc tính cần xóa" }));
            }
            LOAITAILIEU_THUOCTINHBusiness.repository.Delete(id);
            LOAITAILIEU_THUOCTINHBusiness.Save();
            return(Json(new { Type = "SUCCESS", Message = "Xóa thuộc tính thành công" }));
        }