Example #1
0
        public List <BankBranchModel> GetAllBankBranchList(BaseViewModel model)
        {
            List <BankBranchModel> bankBranchList = new List <BankBranchModel>();
            BankBranchModel        bankBranch     = new BankBranchModel();

            try
            {
                List <Master_BankBranch> bankbranchList = _bankBranchRepository.GetAllBankBranchList();

                if (bankbranchList != null)
                {
                    bankbranchList.ForEach(a =>
                    {
                        bankBranch           = Mapper.Map <Master_BankBranch, BankBranchModel>(a);
                        bankBranch.bankModel = Mapper.Map <Master_Bank, BankModel>(a.Master_Bank);

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

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

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

                        bankBranch.ID            = a.ID;
                        bankBranch.CurrentUserID = model.CurrentUserID;

                        bankBranch.CurrentCulture = model.CurrentCulture;
                        bankBranchList.Add(bankBranch);
                    });
                }
            }
            catch (Exception ex)
            {
                IErrorLogService errorLog = new ErrorLogService();
                string           message  = ex.InnerException != null ? ex.InnerException.InnerException.Message : ex.Message;
                errorLog.SetErrorLog(model.CurrentUserID, "BankBranch", message);
                throw new Exception(ex.Message);
            }

            bankBranchList.Sort(CompareBankBranchByName);
            return(bankBranchList);
        }