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 }));
            }
        }
Exemplo n.º 3
0
 public static ChiTietCongViecDTO FromEntity(ChiTietCongViec item)
 {
     return(new ChiTietCongViecDTO()
     {
         Id = item.Id,
         CongViecId = item.CongViecId,
         CongViec = item.CongViec != null?CongViecDTO.FromEntity(item.CongViec) : null,
                        TrangThaiId = item.TrangThaiId,
                        TrangThai = item.TrangThai != null?TrangThaiDTO.FromEntity(item.TrangThai) : null,
                                        TenChiTietCongViec = item.TenChiTietCongViec,
                                        NgayHetHan = item.NgayHetHan,
                                        LichSuChiTietCongViec = item.LichSuChiTietCongViec?.Select(LichSuChiTietCongViecDTO.FromEntity),
                                        BaoCao = item.BaoCao?.Select(BaoCaoDTO.FromEntity),
     });
 }
 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 }));
     }
 }
Exemplo n.º 5
0
 public async Task UpdateChiTietCongViec(ChiTietCongViec chiTietCongViec)
 {
     await _chiTietCongViecRepository.UpdateAsync(chiTietCongViec);
 }
Exemplo n.º 6
0
 public async Task CreateChiTietCongViec(ChiTietCongViec chiTietCongViec)
 {
     await _chiTietCongViecRepository.AddAsync(chiTietCongViec);
 }