/// <summary> /// Ham xu ly chinh, chi nhan 1 bien moi truong /// </summary> /// <param name="context">Bien moi truong</param> /// <returns></returns> public async Task <QuaTrinhCongTacDto> Execute() { Init(); Validate(); // to do: // biz se thuc hien viec abc o day truoc khi goi dac // TODO kiểm tra trạng thái của nhân viên var getNhanVienByIdDac = new GetThongTinNhanVienByIdDac(_context); getNhanVienByIdDac.NHAN_VIEN_ID = NhanVienId; var listNhanVien = (await getNhanVienByIdDac.Execute()).ToList(); if (listNhanVien != null && (listNhanVien.Count() == 0 || listNhanVien[0].XoaYN == "Y")) { throw new BaseException("Không tìm thấy thông tin nhân viên."); } // TODO thêm thông tin quá trình công tác var repo = new QuaTrinhCongTacRepository(_context); var entity = ToEntity(); entity = await repo.UpdatePartial(entity , nameof(TuNgay) , nameof(DenNgay) , nameof(ChucVuId) , nameof(CongViecChinh) , nameof(ThanhTuu) , nameof(Hinh) ); // TODO kiểm tra update thành công bằng CtrVersion if (entity.CtrVersion == CtrVersion) { throw new BaseException("Không thể lưu quá trình công tác"); } // TODO lấy thông tin sau khi update var quaTrinhCongTacBiz = new GetListQuaTrinhCongTacByCriteriaDac(_context); quaTrinhCongTacBiz.QUA_TRINH_CONG_TAC_ID = entity.QuaTrinhCongTacId; var listQuaTrinhCongTac = (await quaTrinhCongTacBiz.Execute()); var result = listQuaTrinhCongTac.FirstOrDefault(); // goi lai ham execute cua tang dac // to do: // biz se thuc hien viec abc voi result truoc khi return return(result); }
/// <summary> /// Ham xu ly chinh, chi nhan 1 bien moi truong /// </summary> /// <param name="context">Bien moi truong</param> /// <returns></returns> public async Task <QuaTrinhCongTacDto> Execute() { Init(); Validate(); // to do: // biz se thuc hien viec abc o day truoc khi goi dac // TODO kiểm tra trạng thái của nhân viên var getNhanVienByIdDac = new GetThongTinNhanVienByIdDac(_context); getNhanVienByIdDac.NHAN_VIEN_ID = NhanVienId; var listNhanVien = (await getNhanVienByIdDac.Execute()).ToList(); if (listNhanVien != null && (listNhanVien.Count() == 0 || listNhanVien[0].XoaYN == "Y")) { throw new BaseException("Không tìm thấy thông tin nhân viên."); } // TODO thêm thông tin quá trình công tác var repo = new QuaTrinhCongTacRepository(_context); var entity = ToEntity(); entity = (await repo.Insert(entity)); if (entity.QuaTrinhCongTacId == 0) { throw new BaseException("Không thể thêm quá trình công tác"); } var quaTrinhCongTacBiz = new GetListQuaTrinhCongTacByCriteriaDac(_context); quaTrinhCongTacBiz.QUA_TRINH_CONG_TAC_ID = entity.QuaTrinhCongTacId; var listQuaTrinhCongTac = (await quaTrinhCongTacBiz.Execute()); var result = listQuaTrinhCongTac.FirstOrDefault(); // goi lai ham execute cua tang dac // to do: // biz se thuc hien viec abc voi result truoc khi return return(result); }