Esempio n. 1
0
 /// <see cref="AddressDAL.GetAddress(int)"/>
 public Address GetAddress(int id)
 {
     if (id < 1)
     {
         throw new ArgumentException("invalid id");
     }
     return(AddressDAL.GetAddress(id));
 }
Esempio n. 2
0
        /// <summary>
        /// Devuelve la dirección según el id informado por parámetro
        /// </summary>
        /// <param name="addressId"></param>
        /// <returns></returns>
        public ResultBM GetAddress(int addressId)
        {
            try
            {
                CountryBLL countryBll = new CountryBLL();
                AddressDAL addressDal = new AddressDAL();
                AddressDTO addressDto = addressDal.GetAddress(addressId);
                AddressBM  addressBm  = null;
                ResultBM   resultCountry;

                // Si la dirección existe, el país debería existir porque de otro modo no podría haberse dado de alta.
                if (addressDto != null)
                {
                    resultCountry = countryBll.GetCountry(addressDto.countryIso);

                    if (!resultCountry.IsValid())
                    {
                        return(resultCountry);
                    }
                    if (resultCountry.GetValue() != null)
                    {
                        addressBm = new AddressBM(addressDto, resultCountry.GetValue <CountryBM>());
                    }
                    else
                    {
                        throw new Exception(SessionHelper.GetTranslation("RETRIEVING_ERROR") + " countryIso " + addressDto.countryIso);
                    }
                }

                return(new ResultBM(ResultBM.Type.OK, "Operación exitosa.", addressBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("RETRIEVING_ERROR") + " " + exception.Message, exception));
            }
        }