public bool Create(ThongTin2CEntity thongTin2CEntity)
        {
            using (var scope = new TransactionScope())
            {
                var tt2C = new ThongTin2Cs
                {
                    Id = thongTin2CEntity.Id,
                    BacLuong = thongTin2CEntity.BacLuong,
                    BiBat_Khaibao_NoiDung = thongTin2CEntity.BiBat_Khaibao_NoiDung,
                    CanNang = thongTin2CEntity.CanNang,
                    ChieuCao = thongTin2CEntity.ChieuCao,
                    CongTacChinhDangLam = thongTin2CEntity.CongTacChinhDangLam,
                    CongViecDaLamLauNhat = thongTin2CEntity.CongViecDaLamLauNhat,
                    DanhHieuDuocPhong = thongTin2CEntity.DanhHieuDuocPhong,
                    DatO = thongTin2CEntity.DatO,
                    DienTichDatO = thongTin2CEntity.DienTichDatO,
                    GiaDinhLietSi = thongTin2CEntity.GiaDinhLietSi,
                    HeSo = thongTin2CEntity.HeSo,
                    HocHamHocViCaoNhat = thongTin2CEntity.HocHamHocViCaoNhat,
                    KhenThuong = thongTin2CEntity.KhenThuong,
                    KyLuat = thongTin2CEntity.KyLuat,
                    LamViecChoCheDoCu = thongTin2CEntity.LamViecChoCheDoCu,
                    LoaiNha = thongTin2CEntity.LoaiNha,
                    Luong_Nam = thongTin2CEntity.Luong_Nam,
                    NamNhan = thongTin2CEntity.NamNhan,
                    NgachCongChuc_ThongTin2C = thongTin2CEntity.NgachCongChuc_ThongTin2C,
                    NgayNhapNgu = thongTin2CEntity.NgayNhapNgu,
                    NgayThamGiaCM = thongTin2CEntity.NgayThamGiaCM,
                    NgayTuyenDung = thongTin2CEntity.NgayTuyenDung,
                    NgayVaoCoQuanDangCongTac = thongTin2CEntity.NgayVaoCoQuanDangCongTac,
                    NgayXuatNgu = thongTin2CEntity.NgayXuatNgu,
                    NgheNghiepTruocTuyenDung = thongTin2CEntity.NgheNghiepTruocTuyenDung,
                    NgoaiNgu_ThongTin2C = thongTin2CEntity.NgoaiNgu_ThongTin2C,
                    NguonKhac = thongTin2CEntity.NguonKhac,
                    NhanThanONuocNgoai = thongTin2CEntity.NhanThanONuocNgoai,
                    ThoiGian = thongTin2CEntity.ThoiGian,
                    ThanhPhanGiaDinh_ThongTin2C = thongTin2CEntity.ThanhPhanGiaDinh_ThongTin2C,
                    NhaO = thongTin2CEntity.NhaO,
                    NhomMau = thongTin2CEntity.NhomMau,
                    QuanHamChucVuCaoNhat = thongTin2CEntity.QuanHamChucVuCaoNhat,
                    QuanHuyen_ThongTin2C = thongTin2CEntity.QuanHuyen_ThongTin2C,
                    XaPhuong = thongTin2CEntity.XaPhuong,
                    VaoCoQuan = thongTin2CEntity.VaoCoQuan,
                    TrinhDoNgoaiNgu_ThongTin2C = thongTin2CEntity.TrinhDoNgoaiNgu_ThongTin2C,
                    TrinhDoLyLuan_ThongTin2C = thongTin2CEntity.TrinhDoLyLuan_ThongTin2C,
                    TongDienTichSuDung = thongTin2CEntity.TongDienTichSuDung,
                    TinhTrangSucKhoe = thongTin2CEntity.TinhTrangSucKhoe,
                    ThuongBinhLoai = thongTin2CEntity.ThuongBinhLoai,
                    ThongTin2C_TinhThanh = thongTin2CEntity.ThongTin2C_TinhThanh,
                    SoTruongCongTac = thongTin2CEntity.SoTruongCongTac,
                    QuanHeVoiToChucNuocNgoai = thongTin2CEntity.QuanHeVoiToChucNuocNgoai
                };

                m_UnitOfWork.ThongTin2CRepository.Insert(tt2C);
                m_UnitOfWork.Save();
                scope.Complete();
                return true;
            }
        }
 public bool Delete(ThongTin2CEntity thongTin2CEntity)
 {
     try
     {
         this.m_UnitOfWork.ThongTin2CRepository.Delete(thongTin2CEntity);
         return true;
     }
     catch (Exception e)
     {
         System.Console.WriteLine(e.ToString());
         return false;
     }
 }
        public ActionResult Delete(ThongTin2CEntity entity)
        {
            ThongTin2CServices service = new ThongTin2CServices();

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

        }
        /// only return json to client
        public ActionResult Create(ThongTin2CEntity entity)
        {
            ThongTin2CServices service = new ThongTin2CServices();
            if (entity == null)
            {
                RenderResult.RequestError(ViewData, "Lỗi đối số không hợp lệ");
                return Json(JsonConvert.SerializeObject(ViewData));
            }

            if (service.Create(entity))
            {
                return Json(RenderResult.RequestCompleted(ViewData, "Thêm thông tin 2c thành công"));
            }
            else
            {

                return Json(RenderResult.RequestCompleted(ViewData, "Lỗi khi thêm thông tin 2c"));
            }
        }
        public ActionResult Edit(ThongTin2CEntity entity)
        {
            ThongTin2CServices service = new ThongTin2CServices();

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

            try
            {
                if (service.Update(entity))
                    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 bool Update(ThongTin2CEntity thongTin2CEntity)
        {
            var success = false;
            if (thongTin2CEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var tt2C = m_UnitOfWork.ThongTin2CRepository.GetByID(thongTin2CEntity.Id);
                    if (tt2C != null)
                    {
                        //tt2C.Id = thongTin2CEntity.Id;
                        tt2C.BacLuong = thongTin2CEntity.BacLuong;
                        tt2C.BiBat_Khaibao_NoiDung = thongTin2CEntity.BiBat_Khaibao_NoiDung;
                        tt2C.CanNang = thongTin2CEntity.CanNang;
                        tt2C.ChieuCao = thongTin2CEntity.ChieuCao;
                        tt2C.CongTacChinhDangLam = thongTin2CEntity.CongTacChinhDangLam;
                        tt2C.CongViecDaLamLauNhat = thongTin2CEntity.CongViecDaLamLauNhat;
                        tt2C.DanhHieuDuocPhong = thongTin2CEntity.DanhHieuDuocPhong;
                        tt2C.DatO = thongTin2CEntity.DatO;
                        tt2C.DienTichDatO = thongTin2CEntity.DienTichDatO;
                        tt2C.GiaDinhLietSi = thongTin2CEntity.GiaDinhLietSi;
                        tt2C.HeSo = thongTin2CEntity.HeSo;
                        tt2C.HocHamHocViCaoNhat = thongTin2CEntity.HocHamHocViCaoNhat;
                        tt2C.KhenThuong = thongTin2CEntity.KhenThuong;
                        tt2C.KyLuat = thongTin2CEntity.KyLuat;
                        tt2C.LamViecChoCheDoCu = thongTin2CEntity.LamViecChoCheDoCu;
                        tt2C.LoaiNha = thongTin2CEntity.LoaiNha;
                        tt2C.Luong_Nam = thongTin2CEntity.Luong_Nam;
                        tt2C.NamNhan = thongTin2CEntity.NamNhan;
                        tt2C.NgachCongChuc_ThongTin2C = thongTin2CEntity.NgachCongChuc_ThongTin2C;
                        tt2C.NgayNhapNgu = thongTin2CEntity.NgayNhapNgu;
                        tt2C.NgayThamGiaCM = thongTin2CEntity.NgayThamGiaCM;
                        tt2C.NgayTuyenDung = thongTin2CEntity.NgayTuyenDung;
                        tt2C.NgayVaoCoQuanDangCongTac = thongTin2CEntity.NgayVaoCoQuanDangCongTac;
                        tt2C.NgayXuatNgu = thongTin2CEntity.NgayXuatNgu;
                        tt2C.NgheNghiepTruocTuyenDung = thongTin2CEntity.NgheNghiepTruocTuyenDung;
                        tt2C.NgoaiNgu_ThongTin2C = thongTin2CEntity.NgoaiNgu_ThongTin2C;
                        tt2C.NguonKhac = thongTin2CEntity.NguonKhac;
                        tt2C.NhanThanONuocNgoai = thongTin2CEntity.NhanThanONuocNgoai;
                        tt2C.ThoiGian = thongTin2CEntity.ThoiGian;
                        tt2C.ThanhPhanGiaDinh_ThongTin2C = thongTin2CEntity.ThanhPhanGiaDinh_ThongTin2C;
                        tt2C.NhaO = thongTin2CEntity.NhaO;
                        tt2C.NhomMau = thongTin2CEntity.NhomMau;
                        tt2C.QuanHamChucVuCaoNhat = thongTin2CEntity.QuanHamChucVuCaoNhat;
                        tt2C.QuanHuyen_ThongTin2C = thongTin2CEntity.QuanHuyen_ThongTin2C;
                        tt2C.XaPhuong = thongTin2CEntity.XaPhuong;
                        tt2C.VaoCoQuan = thongTin2CEntity.VaoCoQuan;
                        tt2C.TrinhDoNgoaiNgu_ThongTin2C = thongTin2CEntity.TrinhDoNgoaiNgu_ThongTin2C;
                        tt2C.TrinhDoLyLuan_ThongTin2C = thongTin2CEntity.TrinhDoLyLuan_ThongTin2C;
                        tt2C.TongDienTichSuDung = thongTin2CEntity.TongDienTichSuDung;
                        tt2C.TinhTrangSucKhoe = thongTin2CEntity.TinhTrangSucKhoe;
                        tt2C.ThuongBinhLoai = thongTin2CEntity.ThuongBinhLoai;
                        tt2C.ThongTin2C_TinhThanh = thongTin2CEntity.ThongTin2C_TinhThanh;
                        tt2C.SoTruongCongTac = thongTin2CEntity.SoTruongCongTac;
                        tt2C.QuanHeVoiToChucNuocNgoai = thongTin2CEntity.QuanHeVoiToChucNuocNgoai;

                        m_UnitOfWork.ThongTin2CRepository.Update(tt2C);
                        m_UnitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return success;
        }
        public List<ThongTin2CEntity> GetAll()
        {
            IEnumerable<ThongTin2Cs> model = this.m_UnitOfWork.ThongTin2CRepository.GetAll();
            List<ThongTin2CEntity> result = new List<ThongTin2CEntity>();

            foreach (var thongTin2CEntity in model)
            {
                ThongTin2CEntity tt2C = new ThongTin2CEntity
                {
                    Id = thongTin2CEntity.Id,
                    BacLuong = thongTin2CEntity.BacLuong,
                    BiBat_Khaibao_NoiDung = thongTin2CEntity.BiBat_Khaibao_NoiDung,
                    CanNang = thongTin2CEntity.CanNang,
                    ChieuCao = thongTin2CEntity.ChieuCao,
                    CongTacChinhDangLam = thongTin2CEntity.CongTacChinhDangLam,
                    CongViecDaLamLauNhat = thongTin2CEntity.CongViecDaLamLauNhat,
                    DanhHieuDuocPhong = thongTin2CEntity.DanhHieuDuocPhong,
                    DatO = thongTin2CEntity.DatO,
                    DienTichDatO = thongTin2CEntity.DienTichDatO,
                    GiaDinhLietSi = thongTin2CEntity.GiaDinhLietSi,
                    HeSo = thongTin2CEntity.HeSo,
                    HocHamHocViCaoNhat = thongTin2CEntity.HocHamHocViCaoNhat,
                    KhenThuong = thongTin2CEntity.KhenThuong,
                    KyLuat = thongTin2CEntity.KyLuat,
                    LamViecChoCheDoCu = thongTin2CEntity.LamViecChoCheDoCu,
                    LoaiNha = thongTin2CEntity.LoaiNha,
                    Luong_Nam = thongTin2CEntity.Luong_Nam,
                    NamNhan = thongTin2CEntity.NamNhan,
                    NgachCongChuc_ThongTin2C = thongTin2CEntity.NgachCongChuc_ThongTin2C,
                    NgayNhapNgu = thongTin2CEntity.NgayNhapNgu,
                    NgayThamGiaCM = thongTin2CEntity.NgayThamGiaCM,
                    NgayTuyenDung = thongTin2CEntity.NgayTuyenDung,
                    NgayVaoCoQuanDangCongTac = thongTin2CEntity.NgayVaoCoQuanDangCongTac,
                    NgayXuatNgu = thongTin2CEntity.NgayXuatNgu,
                    NgheNghiepTruocTuyenDung = thongTin2CEntity.NgheNghiepTruocTuyenDung,
                    NgoaiNgu_ThongTin2C = thongTin2CEntity.NgoaiNgu_ThongTin2C,
                    NguonKhac = thongTin2CEntity.NguonKhac,
                    NhanThanONuocNgoai = thongTin2CEntity.NhanThanONuocNgoai,
                    ThoiGian = thongTin2CEntity.ThoiGian,
                    ThanhPhanGiaDinh_ThongTin2C = thongTin2CEntity.ThanhPhanGiaDinh_ThongTin2C,
                    NhaO = thongTin2CEntity.NhaO,
                    NhomMau = thongTin2CEntity.NhomMau,
                    QuanHamChucVuCaoNhat = thongTin2CEntity.QuanHamChucVuCaoNhat,
                    QuanHuyen_ThongTin2C = thongTin2CEntity.QuanHuyen_ThongTin2C,
                    XaPhuong = thongTin2CEntity.XaPhuong,
                    VaoCoQuan = thongTin2CEntity.VaoCoQuan,
                    TrinhDoNgoaiNgu_ThongTin2C = thongTin2CEntity.TrinhDoNgoaiNgu_ThongTin2C,
                    TrinhDoLyLuan_ThongTin2C = thongTin2CEntity.TrinhDoLyLuan_ThongTin2C,
                    TongDienTichSuDung = thongTin2CEntity.TongDienTichSuDung,
                    TinhTrangSucKhoe = thongTin2CEntity.TinhTrangSucKhoe,
                    ThuongBinhLoai = thongTin2CEntity.ThuongBinhLoai,
                    ThongTin2C_TinhThanh = thongTin2CEntity.ThongTin2C_TinhThanh,
                    SoTruongCongTac = thongTin2CEntity.SoTruongCongTac,
                    QuanHeVoiToChucNuocNgoai = thongTin2CEntity.QuanHeVoiToChucNuocNgoai

                };
                result.Add(tt2C);
            }

            return result;
        }
        public ThongTin2CEntity GetWithId(int Id)
        {
           ThongTin2Cs thongTin2CEntity = m_UnitOfWork.ThongTin2CRepository.GetByID(Id);

            if (thongTin2CEntity != null)
            {
                ThongTin2CEntity item = new ThongTin2CEntity()
                {
                    Id = thongTin2CEntity.Id,
                    BacLuong = thongTin2CEntity.BacLuong,
                    BiBat_Khaibao_NoiDung = thongTin2CEntity.BiBat_Khaibao_NoiDung,
                    CanNang = thongTin2CEntity.CanNang,
                    ChieuCao = thongTin2CEntity.ChieuCao,
                    CongTacChinhDangLam = thongTin2CEntity.CongTacChinhDangLam,
                    CongViecDaLamLauNhat = thongTin2CEntity.CongViecDaLamLauNhat,
                    DanhHieuDuocPhong = thongTin2CEntity.DanhHieuDuocPhong,
                    DatO = thongTin2CEntity.DatO,
                    DienTichDatO = thongTin2CEntity.DienTichDatO,
                    GiaDinhLietSi = thongTin2CEntity.GiaDinhLietSi,
                    HeSo = thongTin2CEntity.HeSo,
                    HocHamHocViCaoNhat = thongTin2CEntity.HocHamHocViCaoNhat,
                    KhenThuong = thongTin2CEntity.KhenThuong,
                    KyLuat = thongTin2CEntity.KyLuat,
                    LamViecChoCheDoCu = thongTin2CEntity.LamViecChoCheDoCu,
                    LoaiNha = thongTin2CEntity.LoaiNha,
                    Luong_Nam = thongTin2CEntity.Luong_Nam,
                    NamNhan = thongTin2CEntity.NamNhan,
                    NgachCongChuc_ThongTin2C = thongTin2CEntity.NgachCongChuc_ThongTin2C,
                    NgayNhapNgu = thongTin2CEntity.NgayNhapNgu,
                    NgayThamGiaCM = thongTin2CEntity.NgayThamGiaCM,
                    NgayTuyenDung = thongTin2CEntity.NgayTuyenDung,
                    NgayVaoCoQuanDangCongTac = thongTin2CEntity.NgayVaoCoQuanDangCongTac,
                    NgayXuatNgu = thongTin2CEntity.NgayXuatNgu,
                    NgheNghiepTruocTuyenDung = thongTin2CEntity.NgheNghiepTruocTuyenDung,
                    NgoaiNgu_ThongTin2C = thongTin2CEntity.NgoaiNgu_ThongTin2C,
                    NguonKhac = thongTin2CEntity.NguonKhac,
                    NhanThanONuocNgoai = thongTin2CEntity.NhanThanONuocNgoai,
                    ThoiGian = thongTin2CEntity.ThoiGian,
                    ThanhPhanGiaDinh_ThongTin2C = thongTin2CEntity.ThanhPhanGiaDinh_ThongTin2C,
                    NhaO = thongTin2CEntity.NhaO,
                    NhomMau = thongTin2CEntity.NhomMau,
                    QuanHamChucVuCaoNhat = thongTin2CEntity.QuanHamChucVuCaoNhat,
                    QuanHuyen_ThongTin2C = thongTin2CEntity.QuanHuyen_ThongTin2C,
                    XaPhuong = thongTin2CEntity.XaPhuong,
                    VaoCoQuan = thongTin2CEntity.VaoCoQuan,
                    TrinhDoNgoaiNgu_ThongTin2C = thongTin2CEntity.TrinhDoNgoaiNgu_ThongTin2C,
                    TrinhDoLyLuan_ThongTin2C = thongTin2CEntity.TrinhDoLyLuan_ThongTin2C,
                    TongDienTichSuDung = thongTin2CEntity.TongDienTichSuDung,
                    TinhTrangSucKhoe = thongTin2CEntity.TinhTrangSucKhoe,
                    ThuongBinhLoai = thongTin2CEntity.ThuongBinhLoai,
                    ThongTin2C_TinhThanh = thongTin2CEntity.ThongTin2C_TinhThanh,
                    SoTruongCongTac = thongTin2CEntity.SoTruongCongTac,
                    QuanHeVoiToChucNuocNgoai = thongTin2CEntity.QuanHeVoiToChucNuocNgoai
                };
                return item;
            }
            else
            {
                return null;
            }
        }