コード例 #1
0
        public DE.StateProvince GetStateProvince(int stateProvinceId)
        {
            try
            {
                using (var context = new StateProvinceContext())
                {
                    StateProvince stateProvince = null;
                    using (var transactionScope = this.GetTransactionScope())
                    {
                        stateProvince = context.StateProvinces.SingleOrDefault(s => s.StateProvinceId == stateProvinceId);

                        transactionScope.Complete();
                    }

                    if (stateProvince == null)
                    {
                        return(null);
                    }

                    var result = new DE.StateProvince();

                    Mapper.Map(stateProvince, result);

                    return(result);
                }
            }
            catch (System.Exception e)
            {
                throw new RepositoryException(
                          string.Format(CultureInfo.CurrentCulture, Strings.ErrorRetrievingStateProvinceById, stateProvinceId),
                          e);
            }
        }
コード例 #2
0
        public ICollection <DE.StateProvince> GetStateProvinces()
        {
            try
            {
                using (var context = new StateProvinceContext())
                {
                    var result = new List <DE.StateProvince>();
                    using (var transactionScope = this.GetTransactionScope())
                    {
                        Mapper.Map(context.StateProvinces, result);
                        transactionScope.Complete();
                    }

                    return(result);
                }
            }
            catch (System.Exception e)
            {
                throw new RepositoryException(Strings.ErrorRetrievingAllStateProvinces, e);
            }
        }