public static int SaveBankAccountInfo(IBankAccountService _bas, int clientId, string bankName, string bankAccountNumber)
        {
            var bank        = _bas.GetBank(bankName);
            var bankAccount = _bas.Create();

            bankAccount.Account_HolderID = clientId;

            if (bank != null)
            {
                bankAccount.BankID = bank.ID;
            }
            else
            {
                bank      = _bas.CreateBank();
                bank.Name = bankName;
                try
                {
                    bankAccount.BankID = _bas.AddBank(bank);
                }
                finally { }
            }

            bankAccount.Account_Number = bankAccountNumber;


            return(_bas.AddBankAccountInfo(bankAccount));
        }
        public static int  SaveDetailFirstNoticeOdLoss(DetailFirstNoticeOfLossViewModel addDetailLoss,
                                                       travel_policy policy,
                                                       IFirstNoticeOfLossService _fis,
                                                       IAdditionalInfoService _ais,
                                                       IBankAccountService _bas)
        {
            try
            {
                var loss = _fis.Create();
                loss.PolicyId   = policy.ID;
                loss.ClaimantId = addDetailLoss.Claimant_ID;
                loss.Relation_claimant_policy_holder = addDetailLoss.RelationClaimantPolicyHolder;
                loss.Destination       = addDetailLoss.Destination;
                loss.Depart_Date_Time  = addDetailLoss.Depart_Date_Time;
                loss.Arrival_Date_Time = addDetailLoss.Arrival_Date_Time;
                loss.Transport_means   = addDetailLoss.Transport_means;
                loss.Total_cost        = addDetailLoss.Total_cost;
                loss.CreatedDateTime   = DateTime.UtcNow;
                loss.FNOL_Number       = _fis.CreateFNOLNumber();

                //loss.Message = "";
                loss.CreatedBy = addDetailLoss.CreatedBy;

                //additional info
                var additionalInfo = _ais.Create();
                additionalInfo.Accident_place    = addDetailLoss.Accident_place;
                additionalInfo.Datetime_accident = addDetailLoss.Datetime_accident;
                var additionalInfoID = _ais.Add(additionalInfo);
                loss.Additional_infoID = additionalInfoID;

                //bank accounts for policy holder
                var holderBankAccountsExist = _bas.CheckIfBankAccountExist(addDetailLoss.Policy_HolderID, addDetailLoss.PolicyHolder_BankAccount, addDetailLoss.PolicyHolder_BankID);
                if (!holderBankAccountsExist)
                {
                    var bankAccount = new bank_account_info();
                    bankAccount.Account_HolderID = addDetailLoss.Policy_HolderID;
                    bankAccount.BankID           = addDetailLoss.PolicyHolder_BankID;
                    bankAccount.Account_Number   = addDetailLoss.PolicyHolder_BankAccount;
                    var policyHolerBankAccount = _bas.AddBankAccountInfo(bankAccount);
                    loss.Policy_holder_bank_accountID = policyHolerBankAccount;
                }
                else
                {
                    var policyHolderBankAccount = _bas.GetBankAccountInfo(addDetailLoss.Policy_HolderID, addDetailLoss.PolicyHolder_BankAccount, addDetailLoss.PolicyHolder_BankID);
                    loss.Policy_holder_bank_accountID = policyHolderBankAccount.ID;
                }

                //bank accounts for claimant
                var claimantBankAccountsExist = _bas.CheckIfBankAccountExist(addDetailLoss.Claimant_ID, addDetailLoss.Claimant_BankAccount, addDetailLoss.Claimant_BankID);
                if (!claimantBankAccountsExist)
                {
                    var bankAccount = new bank_account_info();
                    bankAccount.Account_HolderID = addDetailLoss.Claimant_ID;
                    bankAccount.BankID           = addDetailLoss.Claimant_BankID;
                    bankAccount.Account_Number   = addDetailLoss.Claimant_BankAccount;
                    var claimantBankAccount = _bas.AddBankAccountInfo(bankAccount);
                    loss.Claimant_bank_accountID = claimantBankAccount;
                }
                else
                {
                    var claimantBankAccount = _bas.GetBankAccountInfo(addDetailLoss.Claimant_ID, addDetailLoss.Claimant_BankAccount, addDetailLoss.Claimant_BankID);
                    loss.Claimant_bank_accountID = claimantBankAccount.ID;
                }

                var lossID = _fis.Add(loss);

                if (addDetailLoss.HealthInsurance_Y_N.Equals("Y"))
                {
                    var healthInsuranceInfo = new health_insurance_info
                    {
                        Additional_infoId        = additionalInfoID,
                        additional_info          = additionalInfo,
                        Datetime_doctor_visit    = addDetailLoss.Datetime_doctor_visit,
                        Doctor_info              = addDetailLoss.Doctor_info,
                        Medical_case_description = addDetailLoss.Medical_case_description,
                        Previous_medical_history = addDetailLoss.Previous_medical_history,
                        Responsible_institution  = addDetailLoss.Responsible_institution
                    };

                    _ais.AddHealthInsuranceInfo(healthInsuranceInfo);
                }
                else if (addDetailLoss.LuggageInsurance_Y_N.Equals("Y"))
                {
                    float floaterValue = 0;
                    float.TryParse(addDetailLoss.Floaters_value, out floaterValue);
                    var luggageInsuranceInfo = new luggage_insurance_info
                    {
                        Additional_infoId     = additionalInfoID,
                        additional_info       = additionalInfo,
                        Place_description     = addDetailLoss.Place_description,
                        Detail_description    = addDetailLoss.Detail_description,
                        Report_place          = addDetailLoss.Report_place,
                        Floaters              = addDetailLoss.Floaters,
                        Floaters_value        = floaterValue,
                        Luggage_checking_Time = addDetailLoss.Luggage_checking_Time ?? new TimeSpan(0, 0, 0)
                    };

                    _ais.AddLuggageInsuranceInfo(luggageInsuranceInfo);
                }
                return(lossID);
            }
            catch (Exception e)
            {
                return(-1);
            }
        }