public async Task <long> TongHopThamDinhBoSungChuyen(ThamXet37InputDto input)
        {
            try
            {
                if (input.HoSoId > 0)
                {
                    var hoSo = await _hoSoRepos.GetAsync(input.HoSoId.Value);

                    var hsxl = await _hoSoXuLyRepos.GetAsync(hoSo.HoSoXuLyId_Active.Value);

                    hoSo.TrangThaiHoSo            = (int)CommonENum.TRANG_THAI_HO_SO.SUA_DOI_BO_SUNG;
                    hsxl.TrangThaiXuLy            = input.TrangThaiXuLy;
                    hsxl.DonViGui                 = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET_TONG_HOP;
                    hsxl.DonViXuLy                = (int)CommonENum.DON_VI_XU_LY.TRUONG_PHONG;
                    hsxl.NguoiGuiId               = _session.UserId;
                    hsxl.NguoiXuLyId              = hsxl.TruongPhongId;
                    hsxl.NoiDungCV                = input.NoiDungCV;
                    hsxl.ChuyenVienThuLyDaDuyet   = true;
                    hsxl.ChuyenVienThuLyNgayDuyet = DateTime.Now;
                    hsxl.SoCongVan                = input.SoCongVan;
                    hsxl.NgayYeuCauBoSung         = input.NgayYeuCauBoSung;
                    hsxl.NoiDungYeuCauGiaiQuyet   = input.NoiDungYeuCauGiaiQuyet;
                    hsxl.LyDoYeuCauBoSung         = input.LyDoYeuCauBoSung;
                    hsxl.TenCanBoHoTro            = input.TenCanBoHoTro;
                    hsxl.DienThoaiCanBo           = input.DienThoaiCanBo;

                    hoSo.TenNguoiDaiDien = input.TenNguoiDaiDien;
                    hoSo.SoDienThoai     = input.SoDienThoai;
                    hoSo.DiaChi          = input.DiaChiCoSo;
                    hoSo.Email           = input.Email;
                    hoSo.IsHoSoBS        = true;

                    await _hoSoRepos.UpdateAsync(hoSo);

                    await _hoSoXuLyRepos.UpdateAsync(hsxl);

                    #region Lưu lịch sử
                    var _history = new XHoSoXuLyHistory();
                    _history.HoSoXuLyId  = hsxl.Id;
                    _history.ThuTucId    = hoSo.ThuTucId;
                    _history.NgayXuLy    = DateTime.Now;
                    _history.LuongXuLy   = (int)CommonENum.LUONG_XU_LY_TT37.LUONG_THAM_DINH;
                    _history.HoSoId      = hoSo.Id;
                    _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET_TONG_HOP;
                    _history.NguoiXuLyId = _session.UserId;
                    _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.CHUYEN_VIEN_TONG_HOP_THAM_DINH_BO_SUNG;
                    var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

                    #endregion

                    return(hoSo.Id);
                }
                return(0);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                return(0);
            }
        }
        public async Task TongHopThamDinhLuu(TongHopThamDinhLuu37InputDto input)
        {
            var hoso = await _hoSoRepos.GetAsync(input.HoSoId.Value);

            var hsxl = await _hoSoXuLyRepos.GetAsync(hoso.HoSoXuLyId_Active.Value);

            hsxl.TrangThaiXuLy = input.TrangThaiXuLy;
            hsxl.IsHoSoBS      = false;
            hoso.IsHoSoBS      = false;
            hoso.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_THAM_DINH_HO_SO_37.HO_SO_TONG_HOP_THAM_DINH_DA_LUU;
            if (hsxl.TrangThaiXuLy == (int)CommonENum.KET_QUA_XU_LY.DAT)
            {
                hsxl.HoSoIsDat = true;
            }
            else if (hsxl.TrangThaiXuLy == (int)CommonENum.KET_QUA_XU_LY.KHONG_DAT)
            {
                hsxl.HoSoIsDat = false;
            }
            await _hoSoXuLyRepos.UpdateAsync(hsxl);

            #region Lưu lịch sử
            var _history = new XHoSoXuLyHistory();
            _history.HoSoXuLyId  = hoso.HoSoXuLyId_Active;
            _history.ThuTucId    = hoso.ThuTucId;
            _history.HoSoId      = hoso.Id;
            _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET;
            _history.NguoiXuLyId = _session.UserId;
            _history.NgayXuLy    = DateTime.Now;
            _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.CHUYEN_VIEN_TONG_HOP_THAM_DINH;
            var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

            #endregion
        }
        public async Task CapNhatKetQuaChuyenVanThu(CapNhatKetQuaHoSo37InputDto input)
        {
            var hoso = await _hoSoRepos.GetAsync(input.HoSoId.Value);

            var hsxl = await _hoSoXuLyRepos.GetAsync(hoso.HoSoXuLyId_Active.Value);

            hoso.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_THAM_DINH_HO_SO_37.HO_SO_CHO_VAN_THU_TRA_KET_QUA;

            hsxl.BienBanTongHopUrl = input.BienBanTongHopUrl;
            hsxl.NgayTraKetQua     = DateTime.Now;
            hsxl.NgayGui           = DateTime.Now;
            hsxl.NguoiGuiId        = _session.UserId;
            hsxl.DonViGui          = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET_TONG_HOP;
            hsxl.DonViXuLy         = (int)CommonENum.DON_VI_XU_LY.VAN_THU;

            var _history = new XHoSoXuLyHistory();

            _history.HoSoId      = hoso.Id;
            _history.HoSoXuLyId  = hsxl.Id;
            _history.HoSoIsDat   = hsxl.HoSoIsDat;
            _history.IsHoSoBS    = false;
            _history.NgayXuLy    = DateTime.Now;
            _history.NguoiXuLyId = _session.UserId;
            _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET_TONG_HOP;
            _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.CHUYEN_VIEN_UPLOAD_KET_QUA;
            _history.IsKetThuc   = true;

            await _hoSoXuLyHistoryRepos.InsertAsync(_history);
        }
        public async Task VanThuTraKetQua(long hoSoId)
        {
            var hoso = await _hoSoRepos.GetAsync(hoSoId);

            var hsxl = await _hoSoXuLyRepos.GetAsync(hoso.HoSoXuLyId_Active.Value);

            hsxl.NguoiGuiId      = _session.UserId;
            hsxl.NguoiXuLyId     = hoso.CreatorUserId;
            hsxl.VanThuNgayDuyet = DateTime.Now;
            hsxl.VanThuId        = _session.UserId;
            hsxl.DonViGui        = (int)CommonENum.DON_VI_XU_LY.VAN_THU;
            hsxl.DonViXuLy       = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;

            hoso.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.DA_HOAN_TAT;
            hoso.NgayTraKetQua = DateTime.Now;
            await _hoSoXuLyRepos.UpdateAsync(hsxl);

            await _hoSoRepos.UpdateAsync(hoso);

            var _history = new XHoSoXuLyHistory();

            _history.NgayXuLy    = DateTime.Now;
            _history.HoSoId      = hoso.Id;
            _history.HoSoXuLyId  = hsxl.Id;
            _history.NgayXuLy    = DateTime.Now;
            _history.NguoiXuLyId = _session.UserId;
            _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.VAN_THU;
            _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.VAN_THU_DUYET_THAM_DINH;
            _history.IsKetThuc   = true;

            await _hoSoXuLyHistoryRepos.InsertAsync(_history);
        }
Beispiel #5
0
        public async Task <int> PhanCongPhongBan(PhanCongPhongBan37InputDto input)
        {
            try
            {
                int count = 0;
                foreach (var _id in input.ArrHoSoId)
                {
                    var hoSo = _hoSoRepos.FirstOrDefault(_id);
                    if (hoSo.Id > 0)
                    {
                        if (hoSo.HoSoXuLyId_Active.HasValue)
                        {
                            var hosoxl = _hoSoXuLyRepos.FirstOrDefault(hoSo.HoSoXuLyId_Active.Value);
                            hosoxl.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.PHONG_BAN_PHAN_CONG;
                            hosoxl.DonViGui     = (int)CommonENum.DON_VI_XU_LY.LANH_DAO_CUC;
                            hosoxl.NguoiGuiId   = _session.UserId;
                            hosoxl.NguoiXuLyId  = null;
                            hosoxl.NgayGui      = DateTime.Now;
                            hosoxl.LanhDaoCucId = _session.UserId;
                            hosoxl.LyDoTraLai   = null;
                            #region Lưu lịch sử
                            var _history = new XHoSoXuLyHistory();
                            _history.HoSoXuLyId   = hosoxl.Id;
                            _history.ThuTucId     = hoSo.ThuTucId;
                            _history.HoSoId       = hoSo.Id;
                            _history.NgayXuLy     = DateTime.Now;
                            _history.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.LANH_DAO_CUC;
                            _history.NguoiXuLyId  = _session.UserId;
                            _history.NoiDungYKien = string.Format("Chuyển hồ sơ tới phòng: [{0}] {1}", input.PhongBanId, input.TenPhongBan);
                            _history.ActionEnum   = (int)CommonENum.FORM_FUNCTION.LANH_DAO_PHAN_CONG_HO_SO;

                            var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

                            hosoxl.HoSoXuLyHistoryId_Active = _historyId;
                            #endregion

                            await _hoSoXuLyRepos.UpdateAsync(hosoxl);
                        }

                        hoSo.MotCuaChuyenId   = _session.UserId; // lãnh dạo cục
                        hoSo.NgayMotCuaChuyen = DateTime.Now;
                        hoSo.PhongBanId       = input.PhongBanId;
                        hoSo.TrangThaiHoSo    = (int)CommonENum.TRANG_THAI_HO_SO.LANH_DAO_DA_PHAN_CONG_HO_SO;
                        await _hoSoRepos.UpdateAsync(hoSo);

                        count++;
                    }
                }

                return(count);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                return(0);
            }
        }
        public async Task ThanhLapDoanThamDinh(HoSoDoanThamDinhInputDto input)
        {
            if (input.ListHoSoDoanThamDinh.Count > 0)
            {
                var hoso = await _hoSoRepos.GetAsync(input.HoSoId.Value);

                var hsxl = await _hoSoXuLyRepos.GetAsync(hoso.HoSoXuLyId_Active.Value);

                hoso.TrangThaiHoSo          = (int)CommonENum.TRANG_THAI_THAM_DINH_HO_SO_37.HO_SO_CHO_TONG_HOP_THAM_DINH;
                hoso.IsHoSoBS               = null;
                hsxl.TrangThaiXuLy          = null;
                hsxl.IsHoSoBS               = null;
                hsxl.HoSoIsDat              = null;
                hsxl.LuongXuLy              = (int)CommonENum.LUONG_XU_LY_TT37.LUONG_THAM_DINH;
                hsxl.DonViGui               = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET;
                hsxl.DonViXuLy              = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET_TONG_HOP;
                hsxl.NguoiGuiId             = _session.UserId;
                hsxl.NguoiXuLyId            = hsxl.ChuyenVienThuLyId;
                hsxl.NgayLapDoanThamDinh    = DateTime.Now;
                hsxl.NguoiLapDoanThamDinhId = _session.UserId;

                hsxl.SoCongVan              = null;
                hsxl.NoiDungCV              = null;
                hsxl.NgayYeuCauBoSung       = null;
                hsxl.NoiDungYeuCauGiaiQuyet = null;
                hsxl.LyDoYeuCauBoSung       = null;
                hsxl.TenCanBoHoTro          = null;
                hsxl.DienThoaiCanBo         = null;
                hsxl.TruongPhongDaDuyet     = null;
                hsxl.ChuyenVienThuLyDaDuyet = null;
                hsxl.LanhDaoCucDaDuyet      = null;

                await _hoSoRepos.UpdateAsync(hoso);

                await _hoSoXuLyRepos.UpdateAsync(hsxl);

                foreach (var item in input.ListHoSoDoanThamDinh)
                {
                    var insertInput = item.MapTo <TT37_HoSoDoanThamDinh>();
                    insertInput.ThuTucId = (int)CommonENum.THU_TUC_ID.THU_TUC_37;
                    await _hoSoDoanThamDinh.InsertAsync(insertInput);
                }

                #region Lưu lịch sử
                var _history = new XHoSoXuLyHistory();
                _history.HoSoXuLyId  = hsxl.Id;
                _history.ThuTucId    = hoso.ThuTucId;
                _history.HoSoId      = hoso.Id;
                _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET;
                _history.NguoiXuLyId = _session.UserId;
                _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.LAP_DOAN_THAM_DINH_HO_SO;
                var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

                #endregion
            }
        }
Beispiel #7
0
        public async Task <int> YeuCauThanhToan(PhanCongPhongBan37InputDto input)
        {
            try
            {
                int count = 0;
                foreach (var _id in input.ArrHoSoId)
                {
                    var hoSo = _hoSoRepos.FirstOrDefault(_id);
                    if (hoSo.Id > 0)
                    {
                        if (hoSo.HoSoXuLyId_Active.HasValue)
                        {
                            var hosoxl = _hoSoXuLyRepos.FirstOrDefault(hoSo.HoSoXuLyId_Active.Value);
                            hosoxl.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                            hosoxl.DonViGui    = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                            hosoxl.NguoiGuiId  = _session.UserId;
                            hosoxl.NguoiXuLyId = null;
                            hosoxl.NgayGui     = DateTime.Now;

                            #region Lưu lịch sử
                            var _history = new XHoSoXuLyHistory();
                            _history.HoSoXuLyId   = hosoxl.Id;
                            _history.ThuTucId     = hoSo.ThuTucId;
                            _history.HoSoId       = hoSo.Id;
                            _history.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                            _history.NguoiXuLyId  = _session.UserId;
                            _history.NoiDungYKien = "Đề nghị thanh toán lệ phí hồ sơ!";
                            _history.ActionEnum   = (int)CommonENum.FORM_FUNCTION.MOT_CUA_PHAN_CONG_HO_SO;
                            if (hoSo.PhongBanId.HasValue && hoSo.PhongBanId.Value > 0)
                            {
                                _history.ActionEnum = (int)CommonENum.FORM_FUNCTION.MOT_CUA_PHAN_CONG_LAI_HO_SO;
                            }

                            var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

                            hosoxl.HoSoXuLyHistoryId_Active = _historyId;
                            #endregion

                            await _hoSoXuLyRepos.UpdateAsync(hosoxl);
                        }
                        hoSo.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.CHO_DOANH_NGHIEP_THANH_TOAN;
                        await _hoSoRepos.UpdateAsync(hoSo);

                        count++;
                    }
                }

                return(count);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                return(0);
            }
        }
Beispiel #8
0
        public async Task <int> TuChoiTiepNhan(PhanCongPhongBan37InputDto input)
        {
            try
            {
                int count = 0;
                foreach (var _id in input.ArrHoSoId)
                {
                    var hoSo = _hoSoRepos.FirstOrDefault(_id);

                    if (hoSo.Id > 0)
                    {
                        hoSo.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.MOT_CUA_TRA_LAI;
                        await _hoSoRepos.UpdateAsync(hoSo);

                        if (hoSo.HoSoXuLyId_Active.HasValue)
                        {
                            var hosoxl = _hoSoXuLyRepos.FirstOrDefault(hoSo.HoSoXuLyId_Active.Value);
                            hosoxl.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                            hosoxl.DonViGui    = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                            hosoxl.NguoiGuiId  = _session.UserId;
                            hosoxl.NguoiXuLyId = hoSo.CreatorUserId;
                            hosoxl.YKienGui    = input.LyDoTuChoi;
                            hosoxl.HoSoIsDat   = null;
                            hosoxl.NgayGui     = DateTime.Now;

                            #region Lưu lịch sử
                            var _history = new XHoSoXuLyHistory();
                            _history.HoSoXuLyId   = hosoxl.Id;
                            _history.ThuTucId     = hoSo.ThuTucId;
                            _history.HoSoId       = hoSo.Id;
                            _history.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                            _history.DonViKeTiep  = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                            _history.NguoiXuLyId  = _session.UserId;
                            _history.NoiDungYKien = input.LyDoTuChoi;
                            _history.ActionEnum   = (int)CommonENum.FORM_FUNCTION.MOT_CUA_PHAN_CONG_HO_SO;

                            var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

                            hosoxl.HoSoXuLyHistoryId_Active = null;
                            #endregion

                            await _hoSoXuLyRepos.UpdateAsync(hosoxl);
                        }
                        count++;
                    }
                }
                return(count);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                return(0);
            }
        }
Beispiel #9
0
        public async Task <int> KyGiayTiepNhanVaTraDoanhNghiep(MotCuaTraGiayTiepNhan37InputDto input)
        {
            try
            {
                var hoSo = await _hoSoRepos.GetAsync(input.HoSoId);

                hoSo.SoGiayTiepNhan = input.SoTiepNhan;
                if (!string.IsNullOrEmpty(input.GiayTiepNhanCA))
                {
                    hoSo.GiayTiepNhan = input.GiayTiepNhanCA;
                }
                await _hoSoRepos.UpdateAsync(hoSo);

                var hoSoXuLy = await _hoSoXuLyRepos.GetAsync(input.HoSoXuLyId);

                if (hoSoXuLy != null)
                {
                    #region Lưu lịch sử
                    var _history = new XHoSoXuLyHistory();
                    _history.HoSoXuLyId    = hoSoXuLy.Id;
                    _history.ThuTucId      = hoSo.ThuTucId;
                    _history.HoSoId        = hoSoXuLy.HoSoId;
                    _history.IsHoSoBS      = hoSoXuLy.IsHoSoBS;
                    _history.DonViXuLy     = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                    _history.NguoiXuLyId   = _session.UserId;
                    _history.HoSoIsDat_Pre = hoSoXuLy.HoSoIsDat;
                    _history.HoSoIsDat     = hoSoXuLy.HoSoIsDat;
                    _history.TrangThaiCV   = input.TrangThaiCV;
                    _history.NoiDungCV     = null;
                    _history.NoiDungYKien  = "Bộ phận một cửa trả giấy tiếp nhận";
                    _history.ActionEnum    = (int)CommonENum.FORM_FUNCTION.MOT_CUA_PHAN_CONG_HO_SO;
                    await _hoSoXuLyHistoryRepos.InsertAndGetIdAsync(_history);

                    #endregion
                    hoSoXuLy.NguoiGuiId  = _session.UserId;
                    hoSoXuLy.NguoiXuLyId = null;
                    hoSoXuLy.DonViKeTiep = input.DonViKeTiep;
                    if (!string.IsNullOrEmpty(input.GiayTiepNhanCA))
                    {
                        hoSoXuLy.GiayTiepNhanCA = input.GiayTiepNhanCA;
                    }
                    await _hoSoXuLyRepos.UpdateAsync(hoSoXuLy);
                }
                return(1);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                return(0);
            }
        }
        public async Task VanThuKyVaTraGiayTiepNhan(PhieuTiepNhanInputDto input)
        {
            var hoso = await _hoSoRepos.GetAsync(input.HoSoId);

            var hsxl = await _hoSoXuLyRepos.GetAsync(hoso.HoSoXuLyId_Active.Value);

            if (hoso.IsHoSoBS != true)
            {
                int tenantId  = GetTenantIdFromHoSo(hoso);
                var thanhToan = new ThanhToan()
                {
                    HoSoId            = hoso.Id,
                    DoanhNghiepId     = hoso.DoanhNghiepId,
                    PhiDaNop          = input.PhiDaNop,
                    NgayGiaoDich      = DateTime.Now,
                    PhiXacNhan        = input.PhiDaNop,
                    TenantId          = tenantId,
                    PhanHeId          = _thuTucId,
                    TrangThaiNganHang = (int)CommonENum.TRANG_THAI_GIAO_DICH.GIAO_DICH_THANH_CONG
                };
                hoso.ThanhToanId_Active = await _thanhToanRepos.InsertAndGetIdAsync(thanhToan);
            }

            hsxl.VanThuId            = _session.UserId;
            hsxl.DonViGui            = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
            hsxl.NguoiGuiId          = SessionCustom.UserCurrent.Id;
            hsxl.DonViXuLy           = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
            hsxl.NguoiXuLyId         = SessionCustom.UserCurrent.Id;
            hsxl.NgayGui             = DateTime.Now;
            hsxl.GiayTiepNhanCA      = input.GiayTiepNhanCA;
            hsxl.NgayHenCap          = input.NgayHenCap;
            hsxl.NgayHenTra          = input.NgayHenCap;
            hsxl.HinhThucCapCTJson   = JsonConvert.SerializeObject(input.HinhThucCapChungChi);
            hsxl.TaiLieuDaNhanJson   = JsonConvert.SerializeObject(input.ListTaiLieuDaNhan);
            hsxl.NgayTraGiayTiepNhan = DateTime.Now;

            #region Lưu lịch sử
            var _history = new XHoSoXuLyHistory();
            _history.HoSoId      = hoso.Id;
            _history.HoSoXuLyId  = hsxl.Id;
            _history.LoaiHoSoId  = hoso.LoaiHoSoId;
            _history.NguoiXuLyId = SessionCustom.UserCurrent.Id;
            _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
            _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.MOT_CUA_RA_SOAT_HO_SO;

            _history.NgayXuLy = DateTime.Now;
            var _historyId = _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetId(_history);
            #endregion
        }
        public async Task NopHoSoTraLai(long hoSoId)
        {
            try
            {
                var hoSo = _hoSoRepos.FirstOrDefault(hoSoId);

                if (hoSo.Id > 0)
                {
                    if (hoSo.HoSoXuLyId_Active.HasValue)
                    {
                        var hosoxl = _hoSoXuLyRepos.FirstOrDefault(hoSo.HoSoXuLyId_Active.Value);
                        hosoxl.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                        hosoxl.DonViGui    = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                        hosoxl.NguoiGuiId  = _session.UserId;
                        hosoxl.NguoiXuLyId = hoSo.CreatorUserId;
                        hosoxl.YKienGui    = null;
                        hosoxl.HoSoIsDat   = null;
                        hosoxl.NgayGui     = DateTime.Now;
                        hosoxl.LuongXuLy   = (int)CommonENum.LUONG_XU_LY_TT37.LUONG_RA_SOAT;
                        #region Lưu lịch sử

                        var _history = new XHoSoXuLyHistory();
                        _history.HoSoXuLyId   = hosoxl.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.NoiDungYKien = null;
                        _history.ActionEnum   = (int)CommonENum.FORM_FUNCTION.DOANH_NGHIEP_NOP_HO_SO;

                        var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

                        hosoxl.HoSoXuLyHistoryId_Active = null;

                        #endregion Lưu lịch sử

                        await _hoSoXuLyRepos.UpdateAsync(hosoxl);
                    }
                    hoSo.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.DA_NOP_HO_SO_MOI;
                    await _hoSoRepos.UpdateAsync(hoSo);
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
            }
        }
        public async Task GuiLanhDaoCucPhanCongHoSo(long hoSoId)
        {
            var hoso = await _hoSoRepos.GetAsync(hoSoId);

            var hsxl = await _hoSoXuLyRepos.GetAsync(hoso.HoSoXuLyId_Active.Value);

            int phongBanIdXuLy = GetPhongBanIdXuLyHoSo(hoso);

            if (phongBanIdXuLy > 0)
            {
                hoso.PhongBanId     = phongBanIdXuLy;
                hoso.IsChuyenAuto   = true;
                hoso.NgayChuyenAuto = DateTime.Now;
                hoso.TrangThaiHoSo  = (int)CommonENum.TRANG_THAI_HO_SO.LANH_DAO_DA_PHAN_CONG_HO_SO;

                hsxl.DonViGui  = (int)CommonENum.DON_VI_XU_LY.LANH_DAO_CUC;
                hsxl.DonViXuLy = (int)CommonENum.DON_VI_XU_LY.PHONG_BAN_PHAN_CONG;
            }
            else
            {
                hoso.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.MOT_CUA_DA_TIEP_NHAN;
                hsxl.DonViGui      = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                hsxl.NguoiGuiId    = _session.UserId;
                hsxl.DonViXuLy     = (int)CommonENum.DON_VI_XU_LY.LANH_DAO_CUC;
                hsxl.NguoiXuLyId   = null;

                #region Lưu lịch sử
                var _history = new XHoSoXuLyHistory();
                _history.HoSoId      = hoso.Id;
                _history.HoSoXuLyId  = hsxl.Id;
                _history.LoaiHoSoId  = hoso.LoaiHoSoId;
                _history.NguoiXuLyId = SessionCustom.UserCurrent.Id;
                _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.MOT_CUA_GUI_LANH_DAO;
                _history.NgayXuLy    = DateTime.Now;
                var _historyId = _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetId(_history);
                #endregion
            }

            await _hoSoRepos.UpdateAsync(hoso);

            await _hoSoXuLyRepos.UpdateAsync(hsxl);
        }
Beispiel #13
0
        public async Task PhongBanTraLaiLanhDaoCuc(long hoSoId, string lyDoTraLai)
        {
            var hoso = await _hoSoRepos.GetAsync(hoSoId);

            var hsxl = await _hoSoXuLyRepos.GetAsync(hoSoId);

            hsxl.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.LANH_DAO_CUC;
            hsxl.DonViGui    = (int)CommonENum.DON_VI_XU_LY.PHONG_BAN_PHAN_CONG;
            hsxl.NguoiGuiId  = _session.UserId;
            hsxl.NguoiXuLyId = null;
            hsxl.NgayGui     = DateTime.Now;
            hsxl.LyDoTraLai  = lyDoTraLai;

            hoso.PhongBanId    = null;
            hoso.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.PHONG_BAN_TU_CHOI_TIEP_NHAN_HO_SO;

            #region Lưu lịch sử
            var _history = new XHoSoXuLyHistory();
            _history.HoSoXuLyId   = hsxl.Id;
            _history.ThuTucId     = hoso.ThuTucId;
            _history.NgayXuLy     = DateTime.Now;
            _history.HoSoId       = hoso.Id;
            _history.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.PHONG_BAN_PHAN_CONG;
            _history.NguoiXuLyId  = _session.UserId;
            _history.NoiDungYKien = lyDoTraLai;
            _history.ActionEnum   = (int)CommonENum.FORM_FUNCTION.PHONG_BAN_TRA_LAI;

            var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

            hsxl.HoSoXuLyHistoryId_Active = _historyId;
            #endregion

            await _hoSoRepos.UpdateAsync(hoso);

            await _hoSoXuLyRepos.UpdateAsync(hsxl);

            await _hoSoXuLyHistoryRepos.UpdateAsync(_history);
        }
        // thẩm định hồ sơ
        public async Task ThamDinhHoSo(HoSoThamDinh37InputDto input)
        {
            var hoso = await _hoSoRepos.GetAsync(input.HoSoId.Value);

            var hoSoDoanThamDinh = await _hoSoDoanThamDinh.FirstOrDefaultAsync(x => x.HoSoId == input.HoSoId && x.UserId == _session.UserId);

            hoSoDoanThamDinh.TrangThaiXuLy = input.TrangThaiXuLy;
            hoSoDoanThamDinh.NoiDungYkien  = input.NoiDungYkien;
            await _hoSoDoanThamDinh.UpdateAsync(hoSoDoanThamDinh);

            #region Lưu lịch sử
            var _history = new XHoSoXuLyHistory();
            _history.HoSoXuLyId  = hoso.HoSoXuLyId_Active;
            _history.ThuTucId    = hoso.ThuTucId;
            _history.HoSoId      = hoso.Id;
            _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET;
            _history.NguoiXuLyId = _session.UserId;
            _history.NgayXuLy    = DateTime.Now;
            _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.CHUYEN_GIA_THAM_DINH;
            var _historyId = await _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetIdAsync(_history);

            #endregion
        }
        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);
            }
        }
Beispiel #16
0
        public async Task <int> PhanCongThamDinh(PhanCongThamDinh37InputDto input)
        {
            try
            {
                int count = 0;
                foreach (var _id in input.ArrHoSoId)
                {
                    var hosoxl = _hoSoXuLyRepos.FirstOrDefault(_id);
                    if (hosoxl.Id > 0)
                    {
                        var hoSo = _hoSoRepos.FirstOrDefault(hosoxl.HoSoId);
                        hoSo.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.PHONG_BAN_DA_PHAN_CONG_TOI_CHUYEN_VIEN;
                        #region Lưu lịch sử
                        var _history = new XHoSoXuLyHistory();
                        _history.HoSoXuLyId  = hosoxl.Id;
                        _history.ThuTucId    = hosoxl.ThuTucId;
                        _history.HoSoId      = hosoxl.HoSoId;
                        _history.IsHoSoBS    = hosoxl.IsHoSoBS;
                        _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.PHONG_BAN_PHAN_CONG;
                        _history.NguoiXuLyId = _session.UserId;
                        _history.NgayXuLy    = DateTime.Now;
                        _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.PHONG_BAN_PHAN_CONG;
                        if (hosoxl.ChuyenVienThuLyId != null && hosoxl.ChuyenVienThuLyDaDuyet == null)
                        {
                            _history.ActionEnum = (int)CommonENum.FORM_FUNCTION.PHAN_CONG_LAI_HO_SO_CHUA_XU_LY;
                        }

                        _history.ChuyenVienThuLyId   = input.ChuyenVienThuLyId;
                        _history.ChuyenVienPhoiHopId = input.ChuyenVienPhoiHopId;

                        _history.IsChuyenNhanh = input.IsChuyenNhanh;
                        await _hoSoXuLyHistoryRepos.InsertOrUpdateAsync(_history);

                        #endregion

                        hosoxl.HoSoXuLyHistoryId_Active = null;
                        //Update trạng thái hồ sơ

                        if (!input.TruongPhongId.HasValue)
                        {
                            hosoxl.TruongPhongId = _session.UserId;
                        }
                        else
                        {
                            hosoxl.TruongPhongId = input.TruongPhongId;
                        }
                        hosoxl.ChuyenVienThuLyId   = input.ChuyenVienThuLyId;
                        hosoxl.PhoPhongId          = input.PhoPhongId;
                        hosoxl.ChuyenVienPhoiHopId = input.ChuyenVienPhoiHopId;
                        hosoxl.LyDoTraLai          = null;
                        hosoxl.NguoiXuLyId         = input.ChuyenVienThuLyId;
                        hosoxl.DonViGui            = (int)CommonENum.DON_VI_XU_LY.PHONG_BAN_PHAN_CONG;
                        hosoxl.DonViXuLy           = (int)CommonENum.DON_VI_XU_LY.CHUYEN_VIEN_THAM_XET;

                        hosoxl.NguoiGuiId = _session.UserId;
                        hosoxl.YKienGui   = null;
                        hosoxl.NgayGui    = DateTime.Now;
                        await _hoSoXuLyRepos.UpdateAsync(hosoxl);

                        count++;
                    }
                }

                return(count);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
                return(0);
            }
        }
        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 <long> VanThuRaSoatHoSo(VanThuRaSoatHoSo37Input input)
        {
            var hoso = await _hoSoRepos.FirstOrDefaultAsync(x => x.Id == input.HoSoId);

            var hsxl = await _hoSoXuLyRepos.FirstOrDefaultAsync(x => x.Id == input.HoSoXuLyId);

            if (hoso != null && hsxl != null)
            {
                if (input.TrangThaiXuLy == (int)CommonENum.KET_QUA_XU_LY.DAT)
                {
                    if (hoso.IsHoSoBS != true)
                    {
                        int tenantId  = GetTenantIdFromHoSo(hoso);
                        var thanhToan = new ThanhToan()
                        {
                            HoSoId            = hoso.Id,
                            DoanhNghiepId     = hoso.DoanhNghiepId,
                            PhiDaNop          = input.PhiDaNop,
                            NgayGiaoDich      = DateTime.Now,
                            PhiXacNhan        = input.PhiDaNop,
                            TenantId          = tenantId,
                            PhanHeId          = _thuTucId,
                            TrangThaiNganHang = (int)CommonENum.TRANG_THAI_GIAO_DICH.GIAO_DICH_THANH_CONG
                        };
                        hoso.ThanhToanId_Active = await _thanhToanRepos.InsertAndGetIdAsync(thanhToan);
                    }
                    hoso.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.CHO_TRA_GIAY_TIEP_NHAN;

                    hsxl.VanThuId    = _session.UserId;
                    hsxl.DonViGui    = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                    hsxl.NguoiGuiId  = SessionCustom.UserCurrent.Id;
                    hsxl.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                    hsxl.NguoiXuLyId = SessionCustom.UserCurrent.Id;
                    hsxl.NgayGui     = DateTime.Now;

                    await _hoSoRepos.UpdateAsync(hoso);

                    await _hoSoXuLyRepos.UpdateAsync(hsxl);
                }
                else if (input.TrangThaiXuLy == (int)CommonENum.KET_QUA_XU_LY.KHONG_DAT)
                {
                    hsxl.DonViGui      = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                    hsxl.NguoiGuiId    = SessionCustom.UserCurrent.Id;
                    hsxl.DonViXuLy     = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                    hsxl.LyDoTraLai    = input.LyDoTuChoi;
                    hsxl.NgayGui       = DateTime.Now;
                    hsxl.VanThuId      = _session.UserId;
                    hoso.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.MOT_CUA_TRA_LAI;
                    await _hoSoRepos.UpdateAsync(hoso);

                    await _hoSoXuLyRepos.UpdateAsync(hsxl);
                }

                #region Lưu lịch sử
                var _history = new XHoSoXuLyHistory();
                _history.HoSoId      = hoso.Id;
                _history.HoSoXuLyId  = hsxl.Id;
                _history.LoaiHoSoId  = hoso.LoaiHoSoId;
                _history.NguoiXuLyId = SessionCustom.UserCurrent.Id;
                _history.DonViXuLy   = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN;
                _history.ActionEnum  = (int)CommonENum.FORM_FUNCTION.MOT_CUA_RA_SOAT_HO_SO;

                _history.NgayXuLy = DateTime.Now;
                var _historyId = _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetId(_history);
                #endregion
            }
            return(hoso.Id);
        }
        public async Task DongDau(VanThuXuLy37InputDto input)
        {
            var vanThuId = _session.UserId;

            try
            {
                var hoSo = await _hoSoRepos.FirstOrDefaultAsync(x => x.Id == input.HoSoId);

                var hosoxl = await _hoSoXuLyRepos.FirstOrDefaultAsync(input.HoSoXuLyId);

                if (hosoxl != null && hoSo != null && hosoxl.Id > 0)
                {
                    //hoSo.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.SUA_DOI_BO_SUNG;

                    hosoxl.DonViXuLy     = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                    hosoxl.DonViGui      = (int)CommonENum.DON_VI_XU_LY.VAN_THU;
                    hosoxl.NguoiGuiId    = _session.UserId;
                    hosoxl.NguoiXuLyId   = hoSo.CreatorUserId;
                    hosoxl.NgayGui       = DateTime.Now;
                    hosoxl.VanThuDaDuyet = true;

                    hosoxl.VanThuId          = vanThuId;
                    hosoxl.VanThuIsCA        = true;
                    hosoxl.VanThuNgayDongDau = DateTime.Now;
                    hosoxl.DuongDanTepCA     = input.DuongDanTepCA;
                    hosoxl.YKienGui          = null;

                    await _hoSoRepos.UpdateAsync(hoSo);

                    await _hoSoXuLyRepos.UpdateAsync(hosoxl);

                    if (hosoxl.HoSoIsDat != true)
                    {
                        #region HoSo_Clone

                        var hoSoClone = new XHoSoDto();
                        hoSo.MapTo(hoSoClone);
                        hoSoClone.PId = hoSo.PId != null ? hoSo.PId : hoSo.Id;
                        var  insertInput = hoSoClone.MapTo <XHoSo>();
                        long idClone     = await _hoSoRepos.InsertAndGetIdAsync(insertInput);

                        CurrentUnitOfWork.SaveChanges();
                        var teps = _hoSoTepDinhKemRepos.GetAll()
                                   .Where(x => x.HoSoId == input.HoSoId);

                        foreach (var tep in teps)
                        {
                            var tepNew = new XHoSoTepDinhKem
                            {
                                HoSoId         = insertInput.Id,
                                IsActive       = tep.IsActive,
                                DuongDanTep    = tep.DuongDanTep,
                                IsCA           = tep.IsCA,
                                DaTaiLen       = tep.DaTaiLen,
                                LoaiTepDinhKem = tep.LoaiTepDinhKem,
                                MoTaTep        = tep.MoTaTep,
                                TenTep         = tep.TenTep
                            };
                            await _hoSoTepDinhKemRepos.InsertAsync(tepNew);
                        }
                        #endregion
                    }

                    #region Lưu lịch sử
                    var _history = new XHoSoXuLyHistory();
                    _history.ThuTucId     = hosoxl.ThuTucId;
                    _history.HoSoXuLyId   = hosoxl.Id;
                    _history.HoSoId       = hosoxl.HoSoId;
                    _history.IsHoSoBS     = hosoxl.IsHoSoBS;
                    _history.NguoiXuLyId  = _session.UserId;
                    _history.NoiDungYKien = null;
                    _history.TrangThaiCV  = hosoxl.TrangThaiCV;
                    _history.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.VAN_THU;
                    _history.ActionEnum   = (int)CommonENum.FORM_FUNCTION.VAN_THU_DONG_DAU;

                    _history.HoSoIsDat     = hosoxl.HoSoIsDat;
                    _history.HoSoIsDat_Pre = hosoxl.HoSoIsDat;

                    await _hoSoXuLyHistoryRepos.InsertAndGetIdAsync(_history);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
            }
        }