public JsonResult AddNew(CongViecTuyenDungPostModel data)
 {
     using (DataContext db = new DataContext())
     {
         var error = false;
         try
         {
             CongViecTuyenDung cv = new CongViecTuyenDung();
             cv.TenCongViec = data.TenCongViec;
             cv.DiaDiem     = data.DiaDiem;
             cv.Luong       = data.Luong;
             cv.NgayDang    = data.NgayDang;
             cv.NgayHetHan  = data.NgayHetHan;
             db.CongViecTuyenDungs.Add(cv);
             db.SaveChanges();
             int             max_id = db.CongViecTuyenDungs.Select(x => x.id).Max();
             ChiTietCongViec ct     = new ChiTietCongViec();
             ct.CongViec_ID      = max_id;
             ct.MoTaCongViec     = data.MoTaCongViec;
             ct.ThongTinLienHe   = data.ThongTinLienHe;
             ct.ThuNhapVaPhucLoi = data.ThuNhapVaPhucLoi;
             ct.YeuCau           = data.YeuCau;
             db.ChiTietCongViecs.Add(ct);
             db.SaveChanges();
             error = true;
         }
         catch
         {
             error = false;
         }
         return(Json(new { Error = error }));
     }
 }
        public JsonResult Update(CongViecTuyenDungPostModel data)
        {
            using (DataContext db = new DataContext())
            {
                var error = false;
                try
                {
                    CongViecTuyenDung cv = db.CongViecTuyenDungs.Find(data.id);
                    cv.TenCongViec = data.TenCongViec;
                    cv.DiaDiem     = data.DiaDiem;
                    cv.Luong       = data.Luong;
                    cv.NgayDang    = data.NgayDang;
                    cv.NgayHetHan  = data.NgayHetHan;
                    db.SaveChanges();

                    ChiTietCongViec ct = db.ChiTietCongViecs.Find(data.id);
                    ct.MoTaCongViec     = data.MoTaCongViec;
                    ct.ThongTinLienHe   = data.ThongTinLienHe;
                    ct.ThuNhapVaPhucLoi = data.ThuNhapVaPhucLoi;
                    ct.YeuCau           = data.YeuCau;
                    db.SaveChanges();

                    error = true;
                }
                catch
                {
                    error = false;
                }
                return(Json(new { Error = error }));
            }
        }
 public JsonResult Delete(int id)
 {
     using (DataContext db = new DataContext())
     {
         var error = false;
         try
         {
             ChiTietCongViec ct = db.ChiTietCongViecs.Find(id);
             db.ChiTietCongViecs.Remove(ct);
             db.SaveChanges();
             CongViecTuyenDung cv = db.CongViecTuyenDungs.Find(id);
             db.CongViecTuyenDungs.Remove(cv);
             db.SaveChanges();
             error = true;
         }
         catch
         {
             error = false;
         }
         return(Json(new { Error = error }));
     }
 }