public ZipCodeData GetZipInfo()
        {
            ZipCodeData zipCodeData = null;

            if (_ZipCodeEntity != null)
            {
                zipCodeData = new ZipCodeData()
                {
                    ZipCode = _ZipCodeEntity.Zip,
                    City = _ZipCodeEntity.City,
                    State = _ZipCodeEntity.State.Abbreviation
                };
            }
           
            return zipCodeData;
        }
        public ZipCodeData GetZipInfo(string zip)
        {
            ZipCodeData zipCodeData = null;

            IZipCodeRepository zipCodeRepository = _zipCodeRepository ?? new ZipCodeRepository();
            ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zip);
            if(zipCodeEntity != null)
            {
                zipCodeData = new ZipCodeData
                {
                    City = zipCodeEntity.City,
                    State = zipCodeEntity.State.Abbreviation,
                    ZipCode = zipCodeEntity.Zip
                };
            }
            return zipCodeData;
        }
        public ZipCodeData GetZipInfo()
        {
            ZipCodeData stateFulZipCodeData = null;
            if (_StateFulZipCodeEntity != null)
            {
                stateFulZipCodeData = new ZipCodeData()
                {
                    City = _StateFulZipCodeEntity.City,
                    State = _StateFulZipCodeEntity.State.Abbreviation,
                    ZipCode = _StateFulZipCodeEntity.Zip
                };
            }
            //else
            //    throw new ApplicationException("Oh Ho Ho");

            return stateFulZipCodeData;
        }
Example #4
0
        public ZipCodeData GetZipInfo(string zip)
        {
            ZipCodeData zipCodeData = null;

            IZipCodeRepository zipCodeRepository = _zipRepository ?? new ZipCodeRepository();
            ZipCode zipCode = zipCodeRepository.GetByZip(zip);
            if (zipCode != null)
            {
                zipCodeData = new ZipCodeData
                {
                    City = zipCode.City,
                    State = zipCode.State.Abbreviation,
                    ZipCode = zipCode.Zip,
                };
            }
            _counter++;
            Console.WriteLine("Counter = {0}", _counter);
            return zipCodeData;
        }
        public ZipCodeData GetZipInfo()
        {
            ZipCodeData zipCodeData = null;

            if (this.zipCodeEntity != null)
            {
                zipCodeData = new ZipCodeData()
                {
                    City = this.zipCodeEntity.City,
                    State = this.zipCodeEntity.State.Abbreviation,
                    ZipCode = this.zipCodeEntity.Zip
                };
            }
            //            else
            //            {
            //                throw new ApplicationException("Uh oh");
            //            }
            return zipCodeData;
        }
        public ZipCodeData GetZipInfo(string zip)
        {
            //throw new DivideByZeroException("you cannot try this");
            ZipCodeData zipCodeData = null;

            string hostIdentity = WindowsIdentity.GetCurrent().Name;
            string primaryIdentity = ServiceSecurityContext.Current.PrimaryIdentity.Name;
            string windowsIdentity = ServiceSecurityContext.Current.WindowsIdentity.Name;
            string threadIdentity = Thread.CurrentPrincipal.Identity.Name;


            IZipCodeRepository zipCodeRepository = _zipCodeRespository ?? new ZipCodeRepository();

            ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zip);

            if (zipCodeEntity != null)
            {
                zipCodeData = new ZipCodeData()
                {
                    ZipCode = zipCodeEntity.Zip,
                    City = zipCodeEntity.City,
                    State = zipCodeEntity.State.Abbreviation
                };
            }
            else
            {
                //throw new ApplicationException($"Zip code {zip} not found.");
                //throw new FaultException($"Zip code {zip} not found.");
                //ApplicationException ex = new ApplicationException($"Zip code {zip} not found.");
                //throw new FaultException<ApplicationException>(ex, "Just another message");

                NotFoundData data = new NotFoundData()
                {
                    Message = string.Format($"Zip code {zip} not found."),
                    When = DateTime.Now.ToString(CultureInfo.InvariantCulture),
                    User = "******"
                };
                throw new FaultException<NotFoundData>(data, "No reason");
            }

            return zipCodeData;
        }
        public ZipCodeData GetZipInfo(string zip)
        {
            ZipCodeData zipCodeData = null;

            ZipCode zipCodeEntity = ZipCodeRepositoryInstance.GetByZip(zip);

            if (zipCodeEntity == null) return null;

            zipCodeData = new ZipCodeData()
            {
                City = zipCodeEntity.City,
                State = zipCodeEntity.State.Abbreviation,
                ZipCode = zip
            };

            return zipCodeData;
        }
Example #8
0
        public ZipCodeData GetZipInfo(string zip)
        {
            //Thread.Sleep(10000);
            //throw new DivideByZeroException("you cant do that");

            ZipCodeData zipCodeData = null;
            //Instintiate my zip code repo
            //Go out and get an etntiy
            // and build the zip code data from eneity

            //After adding ctor, we can change some code here
            //Instead of instantiating the zipcode repo here
            // we are going to zipCodeRepo var equal to either the class wide repo that came through ctor
            // or a new zip code repo if that calss wide var is still null meaning we are in wcf not in unit test
            //IZipCodeRepository zipCodeRepo = new ZipCodeRepository();

            IZipCodeRepository zipCodeRepo = _ZipCodeRep ?? new ZipCodeRepository();

            ZipCode zipCodeEntity = zipCodeRepo.GetByZip(zip);
            if (zipCodeEntity != null)
            {
                zipCodeData = new ZipCodeData()
                {
                    City = zipCodeEntity.City,
                    State = zipCodeEntity.State.Abbreviation,
                    ZipCode = zipCodeEntity.Zip
                };
            }
            this._Counter++;
            Console.WriteLine("Count = {0}", this._Counter);
            return zipCodeData;
        }