Exemplo n.º 1
0
        public List <ZipCodeData> GetZipCodes(string state)
        {
            List <ZipCodeData> zipCodeData       = new List <ZipCodeData>();
            IZipCodeRepository zipCodeRepository = _zipCodeRepository ?? new ZipCodeRepository();
            List <ZipCode>     zipCodes          = zipCodeRepository.GetByState(state);

            // ReSharper disable once InvertIf
            if (zipCodes != null)
            {
                // ReSharper disable once LoopCanBeConvertedToQuery
                foreach (ZipCode zipCode in zipCodes)
                {
                    ZipCodeData newZipCodeData = new ZipCodeData
                    {
                        City    = zipCode.City,
                        State   = zipCode.State.Abbreviation,
                        ZipCode = zipCode.Zip
                    };

                    zipCodeData.Add(newZipCodeData);
                }
            }

            return(zipCodeData);
        }
Exemplo n.º 2
0
        public void UpdateZipCty(IEnumerable <ZipCityData> zipCityData)
        {
            IZipCodeRepository rep = _repZip ?? new ZipCodeRepository();
            //This below would be the efficient way to do
            //var cityBatch = zipCityData.ToDictionary(c => c.ZipCode, c => c.City);
            //rep.UpdateZipBatch(cityBatch);


            //For simulate error in a transaction we gonna use this ugly code below
            int counter = 0;

            foreach (var cityData in zipCityData)
            {
                // in a operation without transaction only the first one will succeed.
                //counter++;
                //if (counter==2) throw new FaultException("Sorry, no can do !");

                ZipCode zip = rep.GetByZip(cityData.ZipCode);
                zip.City = cityData.City;
                ZipCode updatedZipCode = rep.Update(zip);
            }

            // To regain control of when and where the transaction is closed
            // it needs to set the TransactionAutoCompleteto false, because the default is true
            // This code below closes the transaction
            OperationContext.Current.SetTransactionComplete();
        }
Exemplo n.º 3
0
        public List <ZipCodeData> GetZipCodes(string state)
        {
            List <ZipCodeData> zipCodeData       = new List <ZipCodeData>();
            IZipCodeRepository zipCodeRepository = _zipCodeRepository ?? new ZipCodeRepository();
            List <ZipCode>     zipCodeList       = zipCodeRepository.GetByState(state);

            // ReSharper disable once InvertIf
            if (zipCodeList != null && zipCodeList.Count > 0)
            {
                // ReSharper disable once LoopCanBeConvertedToQuery
                foreach (ZipCode zipCode in zipCodeList)
                {
                    ZipCodeData newZipCodeData = new ZipCodeData
                    {
                        City    = zipCode.City,
                        State   = zipCode.State.Abbreviation,
                        ZipCode = zipCode.Zip
                    };

                    zipCodeData.Add(newZipCodeData);
                }
            }
            else
            {
                string message = $"State {state} not found";
                throw new FaultException(message);
            }

            return(zipCodeData);
        }
Exemplo n.º 4
0
 public MedicareService(IUserRepository <User> userRepository, ICustomerRepository customerRepository, IMedicareFactory medicareFactory, IStateRepository stateRepository,
                        ICityRepository cityRepository, IZipCodeRepository zipRepository, IProspectCustomerRepository prospectCustomerRepository, IAddressService addressService,
                        ITestRepository testRepository, INdcRepository ndcRepository, ICurrentMedicationRepository currentMedicationRepository, ISettings settings, IRapsRepository rapsRepository,
                        IPreApprovedTestRepository preApprovedTestRepository, ILanguageRepository languageRepository, IEventCustomerResultRepository eventCustomerResultRepository,
                        ICustomerService customerService, IMedicareApiService medicareApiService, IEventCustomerRepository eventCustomerRepository)
 {
     _userRepository              = userRepository;
     _customerRepository          = customerRepository;
     _medicareFactory             = medicareFactory;
     _stateRepository             = stateRepository;
     _cityRepository              = cityRepository;
     _zipRepository               = zipRepository;
     _prospectCustomerRepository  = prospectCustomerRepository;
     _addressService              = addressService;
     _testRepository              = testRepository;
     _ndcRepository               = ndcRepository;
     _currentMedicationRepository = currentMedicationRepository;
     _settings                      = settings;
     _rapsRepository                = rapsRepository;
     _preApprovedTestRepository     = preApprovedTestRepository;
     _languageRepository            = languageRepository;
     _eventCustomerResultRepository = eventCustomerResultRepository;
     _customerService               = customerService;
     _medicareApiService            = medicareApiService;
     _eventCustomerRepository       = eventCustomerRepository;
 }
 public ZipRadiusCustomerCriteriaEditModelValidator(IZipCodeRepository zipCodeRepository)
 {
     _zipCodeRepository = zipCodeRepository;
     RuleFor(x => x.CallQueueId).NotNull().WithMessage("required").NotEmpty().WithMessage("required").GreaterThan(0).WithMessage("must be greater than zero.");
     RuleFor(x => x.ZipCode).NotNull().WithMessage("required").NotEmpty().WithMessage("required").Must((model, zipcode) => IsValidZipCode(zipcode)).WithMessage("provide a valid ZipCode.");
     RuleFor(x => x.HealthPlanId).NotNull().WithMessage("required").NotEmpty().WithMessage("required");
 }
Exemplo n.º 6
0
        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
                };
            }
            else
            {
                ApplicationException ex = new ApplicationException(string.Format("Zip code {0} not found.", zip));
                throw new FaultException <ApplicationException>(ex, "Just another message");
            }

            return(zipCodeData);
        }
Exemplo n.º 7
0
        public IEnumerable <ZipCodeData> GetZips(string zip, int range)
        {
            List <ZipCodeData> zipCodeData = new List <ZipCodeData>();

            IZipCodeRepository zipCodeRepository = _zipCodeRespository ?? new ZipCodeRepository();

            ZipCode zipEntity = zipCodeRepository.GetByZip(zip);

            IEnumerable <ZipCode> zips = zipCodeRepository.GetZipsForRange(zipEntity, range);


            if (zips != null)
            {
                foreach (var zipCode in zips)
                {
                    zipCodeData.Add(new ZipCodeData()
                    {
                        ZipCode = zipCode.Zip,
                        City    = zipCode.City,
                        State   = zipCode.State.Abbreviation
                    });
                }
            }
            return(zipCodeData);
        }
Exemplo n.º 8
0
 public PatientAddressFactory(IStateRepository stateRepository, IZipCodeRepository zipCodeRepository, ICityRepository cityRepository, ICountryRepository countryRepository)
 {
     _stateRepository   = stateRepository;
     _zipCodeRepository = zipCodeRepository;
     _cityRepository    = cityRepository;
     _countryRepository = countryRepository;
 }
Exemplo n.º 9
0
 public ZipCodeService(
     IMapper mapper,
     ILoggerFactory loggerFactory,
     IZipCodeRepository entityRepository)
     : base(mapper, loggerFactory, entityRepository)
 {
 }
        public IEnumerable <ZipCodeData> GetZips(string state)
        {
            List <ZipCodeData> zipCodeData = new List <ZipCodeData>();

            IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository();

            var zips = zipCodeRepository.GetByState(state);

            if (zips != null)
            {
                foreach (ZipCode zipCode in zips)
                {
                    zipCodeData.Add(new ZipCodeData()
                    {
                        City    = zipCode.City,
                        State   = zipCode.State.Abbreviation,
                        ZipCode = zipCode.Zip
                    });
                }
            }

            Console.WriteLine("GetZips(state) called here.");

            return(zipCodeData);
        }
Exemplo n.º 11
0
        public void UpdateZipCity(IEnumerable <ZipCityData> zipCityData)
        {
            IZipCodeRepository repository = _ZipCodeRepository ?? new ZipCodeRepository();

            //Dictionary<string, string> cityBatch = new Dictionary<string, string>();
            //foreach (var zipCity in zipCityData)
            //{
            //    cityBatch.Add(zipCity.ZipCode, zipCity.City);
            //}
            //repository.UpdateBatch(cityBatch);

            int counter = 0;

            foreach (var zipCityItem in zipCityData)
            {
                counter++;
                if (counter == 2)
                {
                    throw new FaultException("Sorry you cannot do that.");
                }
                ZipCode zipEntity = repository.GetByZip(zipCityItem.ZipCode);
                if (zipEntity != null)
                {
                    zipEntity.City = zipCityItem.City;
                    repository.Update(zipEntity);
                }
            }
            OperationContext.Current.SetTransactionComplete();
        }
Exemplo n.º 12
0
        public List <ZipCodeData> GetZipCodes(string zipCode, int zipCodeRange)
        {
            List <ZipCodeData> zipCodeData       = new List <ZipCodeData>();
            IZipCodeRepository zipCodeRepository = _zipCodeRepository ?? new ZipCodeRepository();
            ZipCode            zipCodeEntity     = zipCodeRepository.GetByZipCode(zipCode);
            List <ZipCode>     zipCodeList       = zipCodeRepository.GetZipCodesForRange(zipCodeEntity, zipCodeRange);

            // ReSharper disable once InvertIf
            if (zipCodeList != null && zipCodeList.Count > 0)
            {
                // ReSharper disable once LoopCanBeConvertedToQuery
                foreach (ZipCode zipCode2 in zipCodeList)
                {
                    ZipCodeData newZipCodeData = new ZipCodeData
                    {
                        City    = zipCode2.City,
                        State   = zipCode2.State.Abbreviation,
                        ZipCode = zipCode2.Zip
                    };

                    zipCodeData.Add(newZipCodeData);
                }
            }
            else
            {
                string message = $"Zip code range ({zipCode}, {zipCodeRange}) not found";
                throw new FaultException(message);
            }

            return(zipCodeData);
        }
Exemplo n.º 13
0
        public void UpdateZipCity(IEnumerable <ZipCityData> zipCityData)
        {
            IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository();

            //Dictionary<string,string> cityBatch = new Dictionary<string, string>();

            //foreach (ZipCityData zipCityItem in zipCityData)
            //{
            //    cityBatch.Add(zipCityItem.ZipCode,zipCityItem.City);
            //}

            //zipCodeRepository.UpdateCityBatch(cityBatch);

            int counter = 0;

            foreach (var zipCityItem in zipCityData)
            {
                counter++;

                ZipCode zipEntity = zipCodeRepository.GetByZip(zipCityItem.ZipCode);

                if (zipEntity != null)
                {
                    zipEntity.City = zipCityItem.City;
                    zipCodeRepository.Update(zipEntity);
                    ZipCode updateItem = zipCodeRepository.Update(zipEntity);
                }
            }
        }
Exemplo n.º 14
0
        public ZipCodeData GetZipInfo(string zip)
        {
            //Test after set timeout to 5 seconds. It throws a timeout exception.
            //Thread.Sleep(10000);

            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
                };
            }
            else
            {
                //Used as Unhandled Exception. Sets the proxy state at the client to "Faulted"
                //throw new ApplicationException(string.Format("Zip code {0} not found.", zip));

                //Used as Handled Exception. Keeps the proxy state at the client to "Opened"
                //throw new FaultException(string.Format("Zip code {0} not found.", zip));

                //Used with FaultContract that must be declared at the contract level, the IGeoService in this case. Keeps the proxy state at the client to "Opened"
                //ApplicationException ex = new ApplicationException(string.Format("Zip code {0} not found.", zip));
                //throw new FaultException<ApplicationException>(ex, "Just another message");

                //Better and most powerful way to throw an exception. Using FaultContract that must be declared at the contract level,
                //and using a custom Class to define and send the information needed. Keeps the proxy state at the client to "Opened"
                NotFoundData data = new NotFoundData()
                {
                    Message = string.Format("Zip code {0} not found.", zip),
                    When    = DateTime.Now.ToString(),
                    User    = "******"                  //It can be recovered by Identity or anythin else.
                };

                throw new FaultException <NotFoundData>(data, "Just another message.");
            }

            //lock (this)
            //{
            //    _Counter++;
            //}

            //MyStaticResource.DoSomething();

            //Keep this only if the Host is a Console.
            //Console.WriteLine("Count = {0}", _Counter.ToString());

            //Used in Instancing and Concurrency for demonstration. Need reference to PresentationFramework and using System.Window;
            //MessageBox.Show(string.Format("{0} = {1}, {2}", zip, zipCodeData.City, zipCodeData.State), "Call Counter " + _Counter.ToString());

            return(zipCodeData);
        }
Exemplo n.º 15
0
        public IEnumerable <ZipCodeData> GetZips(string zip, int range)
        {
            List <ZipCodeData> zipCodeData = new List <ZipCodeData>();

            IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository();

            return(zipCodeData);
        }
Exemplo n.º 16
0
        public ZipCodeController(IZipCodeRepository repository, string catalog, LoginView view)
        {
            this._LoginId  = view.LoginId.ToLong();
            this._UserId   = view.UserId.ToInt();
            this._OfficeId = view.OfficeId.ToInt();
            this._Catalog  = catalog;

            this.ZipCodeRepository = repository;
        }
Exemplo n.º 17
0
        public ZipCodeController(IZipCodeRepository repository, string catalog, LoginView view)
        {
            this._LoginId = view.LoginId.ToLong();
            this._UserId = view.UserId.ToInt();
            this._OfficeId = view.OfficeId.ToInt();
            this._Catalog = catalog;

            this.ZipCodeRepository = repository;
        }
Exemplo n.º 18
0
 public BSEWalletManager(IZipCodeRepository zipCodeRepository, IStateRepository stateRepository, ICardRepository cardRepository, ICustomerRepository customerRepository, ITransactionRepository transactionRepository, ILoginRepository login)
 {
     _ZipCodeRepository = zipCodeRepository;
     _StateRepository = stateRepository;
     _CardRepository = cardRepository;
     _CustomerRepository = customerRepository;
     _TransactionRepository = transactionRepository;
     _Login = login;
 }
Exemplo n.º 19
0
        public void UpdateZipCity(string zip, string city)
        {
            IZipCodeRepository repository = _ZipCodeRepository ?? new ZipCodeRepository();
            ZipCode            zipEntity  = repository.GetByZip(zip);

            if (zipEntity != null)
            {
                zipEntity.City = city;
                repository.Update(zipEntity);
            }
        }
Exemplo n.º 20
0
 public FillEventsCallQueueService(IEventRepository eventRepository, IHostRepository hostRepository, ICustomerRepository customerRepository,
                                   IProspectCustomerRepository prospectCustomerRepository, IZipCodeRepository zipCodeRepository, IFillEventsCallQueueHelper fillEventsCallQueueHelper, ISettings settings)
 {
     _hostRepository             = hostRepository;
     _customerRepository         = customerRepository;
     _prospectCustomerRepository = prospectCustomerRepository;
     _zipCodeRepository          = zipCodeRepository;
     _eventRepository            = eventRepository;
     _fillEventsCallQueueHelper  = fillEventsCallQueueHelper;
     _settings = settings;
 }
Exemplo n.º 21
0
 public GlobalCodeService(IGlobalCodeRepository GlobalCodeRepository, IStateRepository stateRepository, ICityRepository cityRepository, IZipCodeRepository zipCodeRepository
                          , IZipCodeRepository2 zipCodeRepository2, IMapper Mapper)
 {
     _globalCodeRepository = GlobalCodeRepository;
     _stateRepository      = stateRepository;
     _cityRepository       = cityRepository;
     _zipCodeRepository    = zipCodeRepository;
     _zipCodeRepository2   = zipCodeRepository2;
     _mapper       = Mapper;
     _mainResponse = new MainResponse();
 }
Exemplo n.º 22
0
        public void UpdateZipCity(IEnumerable <ZipCityData> zipCityData)
        {
            IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository();
            int counter = 0;

            foreach (ZipCityData zipCityItem in zipCityData)
            {
                counter++;

                //if (counter == 2)
                //{
                //    throw new FaultException("sorry, no can do.");
                //}

                ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zipCityItem.ZipCode);
                zipCodeEntity.City = zipCityItem.City;
                ZipCode updateItem = zipCodeRepository.Update(zipCodeEntity);
            }

            //using (TransactionScope scope = new TransactionScope())
            //{

            //    int counter = 0;

            //    foreach (ZipCityData zipCityItem in zipCityData)
            //    {
            //        counter++;

            //        if (counter == 2)
            //        {
            //            throw new FaultException("sorry, no can do.");
            //        }

            //        ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zipCityItem.ZipCode);
            //        zipCodeEntity.City = zipCityItem.City;
            //        ZipCode updateItem = zipCodeRepository.Update(zipCodeEntity);
            //    }

            //    scope.Complete();
            //}

            //OperationContext.Current.SetTransactionComplete();

            //IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository();

            //Dictionary<string, string> cityBatch = new Dictionary<string, string>();

            //foreach (ZipCityData zipCityItem in zipCityData)
            //{
            //    cityBatch.Add(zipCityItem.ZipCode, zipCityItem.City);
            //}

            //zipCodeRepository.UpdateCityBatch(cityBatch);
        }
Exemplo n.º 23
0
 public AddressService(IStateRepository stateRepository, ICityRepository cityRepository, IZipCodeRepository zipCodeRepository,
                       ICountryRepository countryRepository, IValidator <Address> addressValidator, IAddressRepository addressRepository, IZipDataRepository zipDataRepository)
 {
     _countryRepository = countryRepository;
     _stateRepository   = stateRepository;
     _cityRepository    = cityRepository;
     _zipCodeRepository = zipCodeRepository;
     _addressValidator  = addressValidator;
     _addressRepository = addressRepository;
     _zipDataRepository = zipDataRepository;
 }
Exemplo n.º 24
0
        public IZipCodeRepository GetRepository()
        {
            IZipCodeRepository repo = null;

            foreach (var step in _steps)
            {
                repo = step(repo);
            }

            return(repo);
        }
Exemplo n.º 25
0
 public PersonService(IPartyRealRepository partyRealRepository, IPartyRoleRepository partyRoleRepository, IUnitOfWork <HljodritEntitiesDb> unitOfWork, ICountryRepository countryRepository, IZipCodeRepository zipCodeRepository, IPartyContactMediumRepository partyContactMediumRepository, IRecordingPartyRepository recordingPartyRepository, IAlbumRepository albumRepository)
 {
     _partyRoleRepository          = partyRoleRepository;
     _unitOfWork                   = unitOfWork;
     _countryRepository            = countryRepository;
     _zipCodeRepository            = zipCodeRepository;
     _partyContactMediumRepository = partyContactMediumRepository;
     _recordingPartyRepository     = recordingPartyRepository;
     _albumRepository              = albumRepository;
     _partyRealRepository          = partyRealRepository;
 }
Exemplo n.º 26
0
        public void UpdateZipCity(IEnumerable <ZipCityData> zipCityData)
        {
            IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository();

            Dictionary <string, string> cityBatch = new Dictionary <string, string>();

            foreach (ZipCityData zipCityItem in zipCityData)
            {
                cityBatch.Add(zipCityItem.ZipCode, zipCityItem.City);
            }

            zipCodeRepository.UpdateCityBatch(cityBatch);
        }
Exemplo n.º 27
0
        public void UpdateZipCity(string zip, string city)
        {
            IZipCodeRepository rep     = _repZip ?? new ZipCodeRepository();
            ZipCode            zipCode = rep.GetByZip(zip);

            if (zipCode == null)
            {
                return;
            }

            zipCode.City = city;
            rep.Update(zipCode);
        }
Exemplo n.º 28
0
        public IEnumerable <ZipCodeData> GetZip(string state)
        {
            IZipCodeRepository rep = _repZip ?? new ZipCodeRepository();

            IEnumerable <ZipCode>     zipCodes = rep.GetByState(state);
            IEnumerable <ZipCodeData> result   = zipCodes.Select(s => new ZipCodeData
            {
                State   = s.State.Abbreviation,
                ZipCode = s.Zip,
                City    = s.City
            }).ToList();

            return(result);
        }
Exemplo n.º 29
0
        public ZipCodeController()
        {
            this._LoginId = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog = AppUsers.GetCurrentUserDB();

            this.ZipCodeRepository = new MixERP.Net.Schemas.Core.Data.ZipCode
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId = this._UserId
            };
        }
Exemplo n.º 30
0
 public SkillRequestHandler(ILogger <SkillRequestHandler> logger,
                            IPvaAddressLookup pvaAddressLookup,
                            IDeviceApiHttpClient deviceApiHttpClient,
                            IZipCodeRepository zipCodeRepository,
                            IMapImageUrlGenerator mapImageUrlGenerator,
                            IPhoneticAddressHelper phoneticAddressHelper)
 {
     _logger                = logger;
     _pvaAddressLookup      = pvaAddressLookup;
     _deviceApiHttpClient   = deviceApiHttpClient;
     _zipCodeRepository     = zipCodeRepository;
     _mapImageUrlGenerator  = mapImageUrlGenerator;
     _phoneticAddressHelper = phoneticAddressHelper;
 }
Exemplo n.º 31
0
        public ZipCodeController()
        {
            this._LoginId  = AppUsers.GetCurrent().View.LoginId.ToLong();
            this._UserId   = AppUsers.GetCurrent().View.UserId.ToInt();
            this._OfficeId = AppUsers.GetCurrent().View.OfficeId.ToInt();
            this._Catalog  = AppUsers.GetCurrentUserDB();

            this.ZipCodeRepository = new MixERP.Net.Schemas.Core.Data.ZipCode
            {
                _Catalog = this._Catalog,
                _LoginId = this._LoginId,
                _UserId  = this._UserId
            };
        }
Exemplo n.º 32
0
        public ZipCodeData GetZipInfo(string zip)
        {
            // verifying if is coming from unit test  or real call
            IZipCodeRepository rep = _repZip ?? new ZipCodeRepository();

            // Doing the encapsulated thing that it should
            ZipCode zipCode = rep.GetByZip(zip);

            if (zipCode == null)
            {
                Exception ex = new InvalidOperationException("Zip code not found");

                //Every exception thrown by the service will be a FaultException
                //but this will be considered as unhandled one and will receive a generic message
                //throw ex;

                //Even with IncludeExceptionDetailInFaults false is possible to send a fail message
                //this is the simplest form of handled FaultException just explaining the reason.
                //throw new FaultException(new FaultReason("Zip code not found"));

                //Is possible also to send the actual exception details like:
                //message, inner exception, stack trace, etc.
                //just put the ex exception in a new exception detail.
                throw new FaultException <ExceptionDetail>(new ExceptionDetail(ex), "No records");

                // Custom error object.
                //NotFoundData data = new NotFoundData
                //{
                //    Message = "Zip code not found",
                //    When = DateTime.Now.ToString(),
                //    User = "******"
                //};

                //It is possible even send a kind of exception like InvalidOperationException
                // or in this case a custom error object
                //throw new FaultException<NotFoundData>(data, "No records");
            }

            ZipCodeData result = new ZipCodeData
            {
                City    = zipCode.City,
                State   = zipCode.State.Abbreviation,
                ZipCode = zipCode.Zip
            };

            // returning what the client is expecting
            return(result);
        }
Exemplo n.º 33
0
        //[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = false)]
        //[OperationBehavior(TransactionScopeRequired = false)]
        public void UpdateZipCity(IEnumerable <ZipCityData> zipCityData)
        {
            IZipCodeRepository zipCodeRepository = _ZipCodeRepository ?? new ZipCodeRepository();

            #region efficient way of handling batch update
            //Dictionary<string, string> cityBatch = new Dictionary<string, string>();
            //
            //foreach (ZipCityData zipCityItem in zipCityData)
            //    cityBatch.Add(zipCityItem.ZipCode, zipCityItem.City);
            //
            //zipCodeRepository.UpdateCityBatch(cityBatch);
            #endregion

            #region more inefficient, but allows for failing part of it
            int counter = 0;

            foreach (ZipCityData zipCityItem in zipCityData)
            {
                counter++;
                //if (counter == 2)
                //    throw new FaultException("Sorry, no can do.");
                ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zipCityItem.ZipCode);
                zipCodeEntity.City = zipCityItem.City;
                ZipCode updatedItem = zipCodeRepository.Update(zipCodeEntity);
            }

            //OperationContext.Current.SetTransactionComplete();
            #endregion

            #region manual transaction handling
            //using (TransactionScope scope = new TransactionScope())
            //{
            //    int counter = 0;

            //    foreach (ZipCityData zipCityItem in zipCityData)
            //    {
            //        counter++;
            //        if (counter == 2)
            //            throw new FaultException("Sorry, no can do.");
            //        ZipCode zipCodeEntity = zipCodeRepository.GetByZip(zipCityItem.ZipCode);
            //        zipCodeEntity.City = zipCityItem.City;
            //        ZipCode updatedItem = zipCodeRepository.Update(zipCodeEntity);
            //    }

            //    scope.Complete();
            //}
            #endregion
        }
Exemplo n.º 34
0
 public BSEWalletManager(IZipCodeRepository zipCodeRepository)
     : this(zipCodeRepository, null,null,null,null,null)
 {
 }
 public ZipCodesService(IZipCodeRepository zipCodeRepository)
 {
     ZipCodeRepository = zipCodeRepository;
 }
Exemplo n.º 36
0
 public GeoManager(IZipCodeRepository zipCodeRepository)
 {
     _ZipCodeRepository = zipCodeRepository;
 }
Exemplo n.º 37
0
 public GeoManager(IZipCodeRepository zipCodeRepo, IStateRepository stateRepo)
 {
     _ZipCodeRep = zipCodeRepo;
     _StateRepo = stateRepo;
 }
Exemplo n.º 38
0
 public GeoManager(IZipCodeRepository zipCodeRepo)
     : this(zipCodeRepo, null)
 {
     _ZipCodeRep = zipCodeRepo;
 }
 public GeoManager(IZipCodeRepository zipCodeRepository)
     : this(zipCodeRepository, null)
 {
 }
Exemplo n.º 40
0
 public GeoManager(IZipCodeRepository zipRepository)
 {
     this._zipRepository = zipRepository;
 }
Exemplo n.º 41
0
        /// <summary>
        /// The get zip info.
        /// </summary>
        /// <param name="zip">
        /// The zip.
        /// </param>
        /// <returns>
        /// The <see cref="ZipCodeData"/>.
        /// </returns>
        public ZipCodeData GetZipInfo(string zip)
        {
            ZipCodeData zipCodeData = null;
            this.zipCodeRepository = this.zipCodeRepository ?? new ZipCodeRepository();
            var zipCodeEntity = this.zipCodeRepository.GetByZip(zip);
            if (zipCodeEntity != null)
            {
                zipCodeData = new ZipCodeData()
                                  {
                                      City = zipCodeEntity.City,
                                      State = zipCodeEntity.State.Abbreviation,
                                      ZipCode = zipCodeEntity.Zip
                                  };
            }

            return zipCodeData;
        }
Exemplo n.º 42
0
        /// <summary>
        /// The get zips.
        /// </summary>
        /// <param name="zip">
        /// The zip.
        /// </param>
        /// <param name="range">
        /// The range.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable"/>.
        /// </returns>
        public IEnumerable<ZipCodeData> GetZips(string zip, int range)
        {
            List<ZipCodeData> zipCodeData = null;
            this.zipCodeRepository = this.zipCodeRepository ?? new ZipCodeRepository();
            var zipObj = this.zipCodeRepository.GetByZip(zip);
            var zipCodeEntity = this.zipCodeRepository.GetZipsForRange(zipObj, range);
            if (zipCodeEntity != null)
            {
                zipCodeData =
                    zipCodeEntity.Select(
                        code =>
                        new ZipCodeData()
                        {
                            City = code.City,
                            State = code.State.Abbreviation,
                            ZipCode = code.Zip
                        }).ToList();
            }

            return zipCodeData;
        }
 public GeoManager(IZipCodeRepository zipCodeRepository, IStateRepository stateRepository)
 {
     _zipCodeRepository = zipCodeRepository;
     _stateRepositry = stateRepository;
 }
Exemplo n.º 44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeoManager"/> class.
 /// </summary>
 /// <param name="zipCodeRepository">
 /// The zip code repository.
 /// </param>
 /// <param name="stateRepository">
 /// The state repository.
 /// </param>
 public GeoManager(IZipCodeRepository zipCodeRepository, IStateRepository stateRepository)
 {
     this.zipCodeRepository = zipCodeRepository;
     this.stateRepository = stateRepository;
 }