Exemple #1
0
        protected void UpdateRegions(SaveExOzRegionCommand command)
        {
            List <string> apiRegionNames = command.RegionList.Select(w => w.Name).Distinct().ToList();
            var           FilCities      = _cityRepository.GetByNames(apiRegionNames);
            var           exOzRegions    = _exOzRegionRepository.GetByNames(apiRegionNames);

            foreach (var item in command.RegionList)
            {
                ExOzRegion existingExOzRegion = exOzRegions.Where(w => w.RegionId == item.Id).FirstOrDefault();
                City       existingFilCity    = FilCities.Where(w => w.Name == item.Name).FirstOrDefault();

                ExOzState exOzState = _exOzStateRepository.GetByUrlSegment(item.StateUrlSegment);
                State     FilState  = _stateRepository.GetByName(exOzState.Name);

                City FilCityInserted = new City();
                if (existingFilCity == null)
                {
                    var newFilCity = new City
                    {
                        Name      = item.Name,
                        StateId   = FilState.Id,
                        IsEnabled = true,
                    };
                    FilCityInserted = _cityRepository.Save(newFilCity);
                }
                else
                {
                    FilCityInserted = existingFilCity;
                }
                if (existingExOzRegion == null)
                {
                    var newExOzRegion = new ExOzRegion
                    {
                        RegionId      = item.Id,
                        Name          = item.Name,
                        UrlSegment    = item.UrlSegment,
                        StateId       = exOzState.Id,
                        CityId        = FilCityInserted.Id,
                        IsEnabled     = true,
                        Offset        = item.Offset,
                        TimeStamp     = item.Timestamp,
                        OperatorCount = item.Operators.Count,
                        CategoryCount = item.Categories.Count,
                    };
                    ExOzRegion exOzRegionInserted = _exOzRegionRepository.Save(newExOzRegion);
                }
                else
                {
                    existingExOzRegion.IsEnabled = true;
                    ExOzRegion exOzRegionInserted = _exOzRegionRepository.Save(existingExOzRegion);
                }
            }
        }
Exemple #2
0
        protected void UpdateStates(SaveExOzStateCommand command)
        {
            List <string> apiStateNames = command.StateList.Select(w => w.Name).Distinct().ToList();
            var           FilStates     = _stateRepository.GetByNames(apiStateNames);
            var           exOzStates    = _exOzStateRepository.GetByNames(apiStateNames);

            foreach (var item in command.StateList)
            {
                State     existingFilState  = FilStates.Where(w => w.Name == item.Name).FirstOrDefault();
                ExOzState existingExOzState = exOzStates.Where(w => w.StateId == item.Id).FirstOrDefault();

                Country     FilCountry  = _countryRepository.GetByName(item.Country);
                ExOzCountry exOzCountry = _exOzCountryRepository.GetByName(item.Country);

                State FilStateInserted = new State();
                if (existingFilState == null)
                {
                    var newFilState = new State
                    {
                        Name      = item.Name,
                        CountryId = FilCountry.Id,
                        IsEnabled = true,
                    };
                    FilStateInserted = _stateRepository.Save(newFilState);
                }
                else
                {
                    FilStateInserted = existingFilState;
                }
                if (existingExOzState == null)
                {
                    var newExOzState = new ExOzState
                    {
                        StateId    = item.Id,
                        Name       = item.Name,
                        UrlSegment = item.UrlSegment,
                        CountryId  = exOzCountry.Id,
                        StateMapId = FilStateInserted.Id,
                        IsEnabled  = true,
                    };
                    ExOzState exOzStateInserted = _exOzStateRepository.Save(newExOzState);
                }
            }
        }
Exemple #3
0
 public void Delete(ExOzState exOzState)
 {
     _exOzStateRepository.Delete(exOzState);
 }
Exemple #4
0
 public ExOzState Save(ExOzState exOzState)
 {
     return(_exOzStateRepository.Save(exOzState));
 }