示例#1
0
        public List <BankAccountModel> GetAllBankAccountList(BankAccountModel model)
        {
            List <BankAccountModel> bankAccList = new List <BankAccountModel>();
            BankAccountModel        BankAccount = new BankAccountModel();


            try
            {
                List <Master_BankAccount> bankAccountList = _bankAccountRepository.GetAllBankAccountList();

                if (bankAccountList != null)
                {
                    bankAccountList.ForEach(a =>
                    {
                        BankAccount = Mapper.Map <Master_BankAccount, BankAccountModel>(a);

                        BankAccount.bankModel = Mapper.Map <Master_Bank, BankModel>(a.Master_Bank);

                        BankAccount.AccountTypeModel = Mapper.Map <Master_BankAccountType, BankAccountTypeModel>(a.Master_BankAccountType);

                        BankAccount.branchModel = Mapper.Map <Master_BankBranch, BankBranchModel>(a.Master_BankBranch);

                        if (BankAccount.bankModel != null)
                        {
                            BankAccount.bankModel.Name = Utility.GetPropertyValue(BankAccount.bankModel, "Name", model.CurrentCulture) == null ? string.Empty :
                                                         Utility.GetPropertyValue(BankAccount.bankModel, "Name", model.CurrentCulture).ToString();
                        }

                        if (BankAccount.AccountTypeModel != null)
                        {
                            BankAccount.AccountTypeModel.Name = Utility.GetPropertyValue(BankAccount.AccountTypeModel, "Name", model.CurrentCulture) == null ? string.Empty :
                                                                Utility.GetPropertyValue(BankAccount.AccountTypeModel, "Name", model.CurrentCulture).ToString();
                        }

                        if (BankAccount.branchModel != null)
                        {
                            BankAccount.branchModel.Name = Utility.GetPropertyValue(BankAccount.branchModel, "Name", model.CurrentCulture) == null ? string.Empty :
                                                           Utility.GetPropertyValue(BankAccount.branchModel, "Name", model.CurrentCulture).ToString();
                        }

                        BankAccount.AccountName = Utility.GetPropertyValue(BankAccount, "AccountName", model.CurrentCulture) == null ? string.Empty :
                                                  Utility.GetPropertyValue(BankAccount, "AccountName", model.CurrentCulture).ToString();


                        BankAccount.CurrentUserID  = model.CurrentUserID;
                        BankAccount.ID             = a.ID;
                        BankAccount.CurrentCulture = model.CurrentCulture;
                        bankAccList.Add(BankAccount);
                    });
                }
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "Bank Account", message);
                throw new Exception(ex.Message);
            }

            bankAccList.Sort(CompareBankAccountByName);
            return(bankAccList);
        }