public List <DivisionModel> GetDivisionList(BaseViewModel model) { object pValue; string sValue; List <Master_Division> dataList; List <DivisionModel> divisionList = new List <DivisionModel>(); DivisionModel divisionModel = new DivisionModel(); try { dataList = _divRepository.GetDivisionList(); if (dataList != null) { foreach (Master_Division a in dataList) { divisionModel = Mapper.Map <Master_Division, DivisionModel>(a); divisionModel.Country = Mapper.Map <Master_Country, CountryModel>(a.Master_Country); if (divisionModel.Country != null) { pValue = Utility.GetPropertyValue(divisionModel.Country, "Name", model.CurrentCulture); sValue = pValue == null ? string.Empty : pValue.ToString(); divisionModel.Country.Name = sValue; } pValue = Utility.GetPropertyValue(divisionModel, "Name", model.CurrentCulture); sValue = pValue == null ? string.Empty : pValue.ToString(); divisionModel.Name = sValue; divisionModel.CurrentUserID = model.CurrentUserID; divisionModel.CurrentCulture = model.CurrentCulture; divisionList.Add(divisionModel); } } } catch (Exception ex) { string message = LogException(ex, model.CurrentUserID); throw new Exception(message); } divisionList.Sort(CompareDivisionByName); return(divisionList); }