public async Task NopHoSoBoSung(long hoSoId)
        {
            try
            {
                var hoSo = _hoSoRepos.Get(hoSoId);
                if (hoSo == null)
                {
                    return;
                }
                if (hoSo.TrangThaiHoSo == (int)CommonENum.TRANG_THAI_HO_SO.SUA_DOI_BO_SUNG)
                {
                    XHoSoXuLy hoSoXuLyOld = _hoSoXuLyRepos.FirstOrDefault(hoSo.HoSoXuLyId_Active.Value);
                    if (hoSoXuLyOld != null)
                    {
                        XHoSoXuLy hoSoXuLy = new XHoSoXuLy();
                        hoSoXuLy.ThuTucId     = hoSo.ThuTucId;
                        hoSoXuLy.HoSoId       = hoSo.Id;
                        hoSoXuLy.LoaiHoSoId   = hoSo.LoaiHoSoId;
                        hoSoXuLy.QuiTrinh     = hoSoXuLyOld.QuiTrinh;
                        hoSoXuLy.IsHoSoBS     = true;
                        hoSoXuLy.NgayTiepNhan = DateTime.Now;
                        hoSoXuLy.NgayHenTra   = _lichLamViecAppService.GetNgayHenTra(hoSoXuLy.NgayTiepNhan.Value, 7);
                        hoSoXuLy.VanThuId     = hoSoXuLyOld.VanThuId;

                        hoSoXuLy.DonViGui    = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                        hoSoXuLy.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                        hoSoXuLy.NguoiXuLyId = hoSoXuLyOld.VanThuId;

                        hoSoXuLy.LuongXuLy  = (int)CommonENum.LUONG_XU_LY_TT37.LUONG_RA_SOAT;
                        hoSoXuLy.NgayGui    = DateTime.Now;
                        hoSoXuLy.NguoiGuiId = _session.UserId;
                        hoSoXuLy.YKienGui   = null;

                        //Thay đổi hồ sơ xử lý
                        long id = await _hoSoXuLyRepos.InsertAndGetIdAsync(hoSoXuLy);

                        hoSo.HoSoXuLyId_Active = id;

                        hoSo.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.DA_NOP_BO_SUNG;
                        await _hoSoRepos.UpdateAsync(hoSo);

                        #region Lưu lịch sử

                        var _history = new XHoSoXuLyHistory();
                        _history.HoSoXuLyId  = id;
                        _history.ThuTucId    = hoSo.ThuTucId;
                        _history.HoSoId      = hoSo.Id;
                        _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                        _history.DonViKeTiep = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                        _history.NguoiXuLyId = _session.UserId;
                        _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.NOP_HO_SO_BO_SUNG;
                        await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

                        #endregion Lưu lịch sử
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
            }
        }
        public async Task NopHoSoDeRaSoat(HoSoNopRaSoat37InputDto input)
        {
            try
            {
                using (var unitOfWork = _unitOfWorkManager.Begin())
                {
                    var hoso = _hoSoRepos.Get(input.HoSoId);

                    var hsxl = new XHoSoXuLy();

                    if (hoso.HoSoXuLyId_Active.HasValue)
                    {
                        hsxl = _hoSoXuLyRepos.Get(hoso.HoSoXuLyId_Active.Value);
                    }
                    hsxl.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                    hsxl.DonViGui     = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                    hsxl.NguoiGuiId   = _session.UserId;
                    hsxl.HoSoId       = input.HoSoId;
                    hsxl.NgayGui      = DateTime.Now;
                    hsxl.NgayTiepNhan = DateTime.Now;
                    hsxl.LuongXuLy    = (int)CommonENum.LUONG_XU_LY_TT37.LUONG_RA_SOAT;

                    #region Tính Ngày hẹn trả

                    //hsxl.LoaiHoSoId = hoso.LoaiHoSoId;
                    //var loaiHoSo = await _loaiHoSoRepos.FirstOrDefaultAsync(x => x.Id == hoso.LoaiHoSoId);
                    //if (loaiHoSo != null && loaiHoSo.SoNgayXuLy.HasValue)
                    //{
                    //    DateTime ngayHenTra = _lichLamViecAppService.GetNgayHenTra(hsxl.NgayTiepNhan.Value, loaiHoSo.SoNgayXuLy.Value);
                    //    hsxl.NgayHenTra = ngayHenTra;
                    //}

                    #endregion Tính Ngày hẹn trả

                    var _hsxlId = await _hoSoXuLyRepos.InsertOrUpdateAndGetIdAsync(hsxl);

                    //Thêm History
                    var history = new XHoSoXuLyHistory();
                    history.NgayXuLy    = DateTime.Now;
                    history.HoSoId      = input.HoSoId;
                    history.HoSoXuLyId  = _hsxlId;
                    history.ThuTucId    = hoso.ThuTucId;
                    history.NguoiXuLyId = _session.UserId;
                    history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                    history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.DOANH_NGHIEP_NOP_HO_SO;
                    await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(history);

                    //Update trang thai ho so doanh nghiep
                    hoso.IsCA              = true;
                    hoso.DuongDanTepCA     = input.DuongDanTep;
                    hoso.TrangThaiHoSo     = (int)CommonENum.TRANG_THAI_HO_SO.DA_NOP_HO_SO_MOI;
                    hoso.HoSoXuLyId_Active = _hsxlId;
                    hoso.NgayNopRaSoat     = DateTime.Now;
                    await _hoSoRepos.UpdateAsync(hoso);

                    unitOfWork.Complete();
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
            }
        }