//creates a number of pilots
        public static void CreatePilots(int count)
        {
            List <Town> towns = Towns.GetTowns();

            Random rnd = new Random();

            for (int i = 0; i < count; i++)
            {
                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-Pilot.RetirementAge), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(), Names.GetInstance().getRandomLastName(), birthdate, town);

                Dictionary <Pilot.PilotRating, int> rankings = new Dictionary <Pilot.PilotRating, int>();
                rankings.Add(Pilot.PilotRating.A, 10);
                rankings.Add(Pilot.PilotRating.B, 20);
                rankings.Add(Pilot.PilotRating.C, 40);
                rankings.Add(Pilot.PilotRating.D, 20);
                rankings.Add(Pilot.PilotRating.E, 10);

                Pilot.PilotRating ranking = AIHelpers.GetRandomItem <Pilot.PilotRating>(rankings);

                int fromYear = Math.Min(GameObject.GetInstance().GameTime.Year - 1, birthdate.AddYears(23).Year);
                int toYear   = Math.Min(GameObject.GetInstance().GameTime.Year, birthdate.AddYears(Pilot.RetirementAge).Year);

                DateTime educationTime = MathHelpers.GetRandomDate(birthdate.AddYears(23), new DateTime(toYear, 1, 1));
                Pilot    pilot         = new Pilot(profile, educationTime, ranking);

                Pilots.AddPilot(pilot);
            }
        }
        public TownsResponse Post(Towns request)
        {
            if (request.Town.Id > 0)
              {
            Bm2s.Data.Common.BLL.Parameter.Town item = Datas.Instance.DataStorage.Towns[request.Town.Id];
            item.CountryId = request.Town.Country.Id;
            item.EndingDate = request.Town.EndingDate;
            item.Name = request.Town.Name;
            item.StartingDate = request.Town.StartingDate;
            item.ZipCode = request.Town.ZipCode;
            Datas.Instance.DataStorage.Towns[request.Town.Id] = item;
              }
              else
              {
            Bm2s.Data.Common.BLL.Parameter.Town item = new Data.Common.BLL.Parameter.Town()
            {
              CountryId = request.Town.Country.Id,
              EndingDate = request.Town.EndingDate,
              Name = request.Town.Name,
              StartingDate = request.Town.StartingDate,
              ZipCode = request.Town.ZipCode
            };

            Datas.Instance.DataStorage.Towns.Add(item);
            request.Town.Id = item.Id;
              }

              TownsResponse response = new TownsResponse();
              response.Towns.Add(request.Town);
              return response;
        }
Example #3
0
        public void TestUpdateTowns()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "TestUpdateTownsDB")
                          .Options;

            var data = new List <Towns>()
            {
                new Towns {
                    Id = 1, Name = "Town1"
                },
                new Towns {
                    Id = 2, Name = "Town2"
                },
                new Towns {
                    Id = 3, Name = "Town3"
                },
            }.AsQueryable();

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                TownsBusiness business = new TownsBusiness(context);
                data.ToList().ForEach(c => business.AddTown(c));

                Towns c = business.GetTownById(2); c.Name = "Town22";
                business.UpdateTown(c);

                Assert.AreEqual("Town22", business.GetTownById(2).Name);
            }
        }
Example #4
0
        /// <summary>
        /// Register employee with given FirstName, LastName, Password
        /// Check if there already Town in the database and creates if there is not
        /// </summary>
        /// <param name="FirstName">Given FirstName</param>
        /// <param name="LastName">GIven LastName</param>
        /// <param name="Password">Given passwor</param>
        /// <param name="TownName">Given TownName</param>
        public void Register(string FirstName, string LastName, string TownName, string Password)
        {
            //Registe employee
            var Town = this.officestoreContext.Towns.FirstOrDefault(a => a.Name == TownName);

            if (Town == null)//Checks if Town exists
            {
                //Creates new town
                Town = new Towns()
                {
                    Name = TownName
                };
                this.officestoreContext.Towns.Add(Town);
            }
            Employees employee = new Employees()
            {
                FirstName = FirstName,
                LastName  = LastName,
                TownId    = Town.Id,
                Password  = Password,
                DutyId    = 1
            };

            this.officestoreContext.Employees.Add(employee);
            this.officestoreContext.SaveChanges();
        }
        public void LoadCurrents(AbsolutePlace place)
        {
            var countries = namazApi.GetCountries();

            countries.ForEach(c => Countries.Add(c));

            if (!string.IsNullOrWhiteSpace(place.Country?.UlkeID) &&
                Countries.Any())
            {
                var selectedCnt = Countries.FirstOrDefault(c => c.UlkeID == place.Country?.UlkeID);
                SelectedCountry = selectedCnt;

                var cities = namazApi.GetCities(selectedCnt.UlkeID);
                cities.ForEach(c => Cities.Add(c));

                if (!string.IsNullOrWhiteSpace(place.City?.SehirID))
                {
                    var selectedCity = Cities.FirstOrDefault(c => c.SehirID == place.City?.SehirID);
                    SelectedCity = selectedCity;

                    var towns = namazApi.GetTowns(selectedCity.SehirID);
                    towns.ForEach(i => Towns.Add(i));
                    if (!string.IsNullOrWhiteSpace(place.Town?.IlceID))
                    {
                        var selectedTown = Towns.FirstOrDefault(t => t.IlceID == place.Town?.IlceID);
                        SelectedTown = SelectedTown;
                    }
                    else
                    {
                        var cityCenter = towns.FirstOrDefault(t => t.IlceAdi == selectedCity.SehirAdi);
                        SelectedTown = cityCenter;
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// 在省级区划范围内尝试通过县级区划反向查询市级区划
        /// </summary>
        private void FindCityReverse()
        {
            var list = (from r in _Citys
                        join c in Countys on r.ID equals c.ParentId
                        let alias = c.Alias.Split(',').FirstOrDefault(_Address.Contains)
                                    let key = alias ?? c.Name
                                              let index = GetIndex(key)
                                                          where index >= 0
                                                          orderby index
                                                          select new { region = c, index, key }).ToList();

            if (!list.Any())
            {
                if (!"北京,天津,上海,重庆".Contains(_Province.Alias))
                {
                    return;
                }

                _City = Citys.Single(c => c.ParentId == _Province.ID && c.Name == "市辖区");
                return;
            }

            var county = list.First();

            _County = county.region;
            _City   = Citys.Single(c => c.ID == _County.ParentId);
            _Towns  = Towns.Where(t => t.ParentId == _County.ID).ToList();

            SetIndex(county.index, _County.Name, county.key);
            FindTown();
        }
Example #7
0
        /// <summary>
        /// Get towns sorted by distance to passed ID town.
        /// </summary>
        public List <string> GetTownsSortedByDistance(string p_ID)
        {
            var l_Town = Towns.Single(x => x.TownID == p_ID);

            var l_SortedTowns = Towns.Select(town => town.TownID).ToList();

            for (var i = 0; i < Towns.Count; i++)
            {
                var min         = i;
                var minDistance = Math.Sqrt(
                    Math.Pow(Math.Abs((int.Parse(l_Town.IslandX) - int.Parse(Towns.Single(x => x.TownID == l_SortedTowns[i]).IslandX))), 2) +
                    Math.Pow(Math.Abs((int.Parse(l_Town.IslandY) - int.Parse(Towns.Single(x => x.TownID == l_SortedTowns[i]).IslandY))), 2));

                int j;
                for (j = i + 1; j < Towns.Count; j++)
                {
                    var curDistance = Math.Sqrt(
                        Math.Pow(Math.Abs((int.Parse(l_Town.IslandX) - int.Parse(Towns.Single(x => x.TownID == l_SortedTowns[j]).IslandX))), 2) +
                        Math.Pow(Math.Abs((int.Parse(l_Town.IslandY) - int.Parse(Towns.Single(x => x.TownID == l_SortedTowns[j]).IslandY))), 2));

                    if (curDistance < minDistance)
                    {
                        min         = j;
                        minDistance = curDistance;
                    }
                }
                var l_TownIndex = l_SortedTowns[min];
                l_SortedTowns[min] = l_SortedTowns[i];
                l_SortedTowns[i]   = l_TownIndex;
            }
            return(l_SortedTowns);
        }
Example #8
0
        public void GetTownByName()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetTownByNameDB")
                          .Options;

            var data = new List <Towns>()
            {
                new Towns {
                    Id = 1, Name = "Town1"
                },
                new Towns {
                    Id = 2, Name = "Town2"
                },
                new Towns {
                    Id = 3, Name = "Town3"
                },
            }.AsQueryable();

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                TownsBusiness business = new TownsBusiness(context);
                data.ToList().ForEach(t => business.AddTown(t));

                Towns t = business.GetTownByName("Town1");
                Assert.AreEqual("Town1", t.Name);
            }
        }
 public void BindExistingData()
 {
     if (ProductItemViewModel != null)
     {
         Title               = "Edit Product";
         SelectedTown        = Towns.FirstOrDefault(x => x.Id == ProductItemViewModel.TownId);
         SelectedListingType = ListingTypes.FirstOrDefault(x => x.Id == ProductItemViewModel.ListingTypeId);
         ProductName         = ProductItemViewModel.ProductName;
         IsHot               = ProductItemViewModel.IsHot;
         Area             = ProductItemViewModel.Area;
         HouseNumber      = ProductItemViewModel.HouseNumber;
         SalePrice        = (float)ProductItemViewModel.SalePrice;
         SelectedSaleUnit = SaleUnits.FirstOrDefault(x => x.Id == ProductItemViewModel.SaleUnitId);
         RentPrice        = (float)ProductItemViewModel.RentPrice;
         SelectedRentUnit = RentUnits.FirstOrDefault(x => x.Id == ProductItemViewModel.RentUnitId);
         Mobile           = ProductItemViewModel.OwnerInfo.Mobile;
         OwnerName        = ProductItemViewModel.OwnerInfo.Name;
         Notes            = ProductItemViewModel.Notes;
         if (ProductItemViewModel.ImageUrls != null && ProductItemViewModel.ImageUrls.Any())
         {
             Photos = new ObservableCollection <ImageItemViewModel>(ProductItemViewModel.ImageUrls.Select(x => new ImageItemViewModel
             {
                 Id          = x.Id,
                 ImageName   = x.Name,
                 ImageSource = new UriImageSource {
                     Uri = new Uri(x.Url)
                 }
             }));
         }
     }
     else
     {
         Title = "Add Product";
     }
 }
Example #10
0
 /// <summary>
 /// Set Count of Unit in specific town.
 /// </summary>
 /// <param name="p_Unit">Unit name</param>
 /// <param name="p_Count">Unit count</param>
 /// <param name="p_HomeTown">HomeTown ID</param>
 /// <param name="p_CurrentTown">CurrentTown ID</param>
 public void SetUnitCount(string p_Unit, string p_Count, string p_HomeTown, string p_CurrentTown)
 {
     if (p_HomeTown.Equals(p_CurrentTown))
     {
         var l_UnitIndex = Towns.Single(x => x.TownID == p_HomeTown).ArmyUnits.FindIndex(a => a.Name.ToString("G") == p_Unit);
         if (l_UnitIndex != -1)//All unknown or ignored units give -1, e.g. militia
         {
             Towns.Single(x => x.TownID == p_HomeTown).ArmyUnits[l_UnitIndex].CurrentAmount = int.Parse(p_Count);
             Towns.Single(x => x.TownID == p_HomeTown).ArmyUnits[l_UnitIndex].TotalAmount  += int.Parse(p_Count);
         }
     }
     else
     {
         foreach (var town in Towns)
         {
             if (town.TownID.Equals(p_HomeTown))
             {
                 var l_UnitIndex = Towns.Single(x => x.TownID == p_HomeTown).ArmyUnits.FindIndex(a => a.Name.ToString("g") == p_Unit);
                 if (l_UnitIndex != -1)//All unknown or ignored units give -1, e.g. militia
                 {
                     Towns.Single(x => x.TownID == p_HomeTown).ArmyUnits[l_UnitIndex].TotalAmount += int.Parse(p_Count);
                 }
                 break;
             }
         }
     }
 }
Example #11
0
        private static bool ParseTowns(NodeStruct node, FileLoader fileLoader)
        {
            byte       type;
            NodeStruct nodeTown = fileLoader.GetChildNode(node, out type);

            while (nodeTown != null)
            {
                if (type != (byte)OtbmNodeTypes.Town)
                {
                    return(false);
                }

                MemoryStream props;
                if (!fileLoader.GetProps(nodeTown, out props))
                {
                    return(false);
                }

                uint townId = props.ReadUInt32();
                if (!Towns.ContainsKey(townId))
                {
                    Towns.Add(townId, new Town {
                        TownId = townId
                    });
                }
                Town town = Towns[townId];

                town.TownName       = props.GetString();
                town.TemplePosition = new Position(props.ReadUInt16(), props.ReadUInt16(), (byte)props.ReadByte());

                nodeTown = fileLoader.GetNextNode(nodeTown, out type);
            }

            return(true);
        }
    //Method to unlock new town
    public static bool UnlockNewTown(Towns newTown)
    {
        int newTownCost = NextPurchaseCost();

        if (Inventory.Instance.GetUnlockedTowns().Contains(newTown))
        {
            Debug.Log("UnlockNewTown(): " + newTown.ToString() + " is already unlocked.");
            return(false);
        }

        if (Inventory.Instance.RemoveGold(newTownCost))
        {
            Inventory.Instance.UnlockTown(newTown);
            AchievementManager.Get("unlock_town_01");
            AchievementManager.Increment("all_towns");
            //unlockedTowns.Add(newTown);
            //lockedTowns.Remove(newTown);
            Debug.Log("Town is unlocked: " + newTown);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Example #13
0
 private void PrintTown(Towns town)
 {
     Console.WriteLine(new string('-', 40));
     Console.WriteLine($"ID: {town.Id}");
     Console.WriteLine($"Name: {town.Name}");
     Console.WriteLine(new string('-', 40));
 }
 public static void ChangeCurrentTown(Towns newTown)
 {
     if (Inventory.Instance.GetUnlockedTowns().Contains(newTown))
     {
         Inventory.Instance.SetCurrentTown(newTown);
     }
 }
Example #15
0
        //creates a number of pilots
        public static void CreatePilots(int count)
        {
            List <Town> towns = Towns.GetTowns();

            Random rnd = new Random();

            for (int i = 0; i < count; i++)
            {
                Town     town      = towns[rnd.Next(towns.Count)];
                DateTime birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-Pilot.RetirementAge), GameObject.GetInstance().GameTime.AddYears(-23));

                PilotProfile profile = new PilotProfile(Names.GetInstance().getRandomFirstName(town.Country), Names.GetInstance().getRandomLastName(town.Country), birthdate, town);

                PilotRating rating = GetPilotRating();

                int fromYear = Math.Min(GameObject.GetInstance().GameTime.Year - 1, birthdate.AddYears(23).Year);
                int toYear   = Math.Min(GameObject.GetInstance().GameTime.Year, birthdate.AddYears(Pilot.RetirementAge).Year);

                DateTime educationTime = MathHelpers.GetRandomDate(birthdate.AddYears(23), new DateTime(toYear, 1, 1));
                Pilot    pilot         = new Pilot(profile, educationTime, rating);

                pilot.Aircrafts = GetPilotAircrafts(pilot);

                Pilots.AddPilot(pilot);
            }
        }
Example #16
0
        //creates a number of instructors
        public static void CreateInstructors(int count)
        {
            List <Town> towns = Towns.GetTowns();

            Random rnd = new Random();

            for (int i = 0; i < count; i++)
            {
                Town         town      = towns[rnd.Next(towns.Count)];
                DateTime     birthdate = MathHelpers.GetRandomDate(GameObject.GetInstance().GameTime.AddYears(-Pilot.RetirementAge), GameObject.GetInstance().GameTime.AddYears(-23));
                PilotProfile profile   = new PilotProfile(Names.GetInstance().getRandomFirstName(town.Country), Names.GetInstance().getRandomLastName(town.Country), birthdate, town);

                Dictionary <PilotRating, int> rankings = new Dictionary <PilotRating, int>();
                rankings.Add(PilotRatings.GetRating("A"), 10);
                rankings.Add(PilotRatings.GetRating("B"), 20);
                rankings.Add(PilotRatings.GetRating("C"), 40);
                rankings.Add(PilotRatings.GetRating("D"), 20);
                rankings.Add(PilotRatings.GetRating("E"), 10);

                PilotRating ranking = AIHelpers.GetRandomItem <PilotRating>(rankings);

                Instructor instructor = new Instructor(profile, ranking);

                Instructors.AddInstructor(instructor);
            }
        }
Example #17
0
        public IHttpActionResult PutTowns(int id, Towns towns)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != towns.ID)
            {
                return(BadRequest());
            }

            db.Entry(towns).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TownsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #18
0
 public static Town GetTown(ushort townId)
 {
     if (Towns.ContainsKey(townId))
     {
         return(Towns[townId]);
     }
     return(null);
 }
Example #19
0
        public void CreateTown(Account Player, UserGameSettings Settings)
        {
            Towns NewTown = new Towns();

            SettingStats(Settings);
            SettingTown(NewTown, Player);
            Player.Towns.Add(NewTown);
        }
Example #20
0
        public ActionResult DeleteConfirmed(int id)
        {
            Towns towns = db.Ilceler.Find(id);

            db.Ilceler.Remove(towns);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #21
0
        public void TownsClassTest()
        {
            // Arrange & Act
            Towns towns = new Towns();

            //Assert
            Assert.IsNotNull(towns);
        }
Example #22
0
 public static Towns Instance()
 {
     if (_instance == null)
     {
         _instance = new Towns();
     }
     return(_instance);
 }
Example #23
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Towns towns = await db.Towns.FindAsync(id);

            db.Towns.Remove(towns);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #24
0
        /// <summary>
        /// Убрать город
        /// </summary>
        /// <param name="Name">Название города</param>
        public static void RemoveTown(string Name)
        {
            Town finded = Towns.Find(x => x.Name == Name);

            if (finded != null)
            {
                Towns.Remove(finded);
            }
        }
Example #25
0
    public void Setup(Town town, Towns towns, Inventory inventory, GameDate gameDate)
    {
        this.town      = town;
        this.towns     = towns;
        this.inventory = inventory;
        this.gameDate  = gameDate;

        FillRumors();
    }
Example #26
0
        public void InitializeTowns(IEnumerable <TownEntity> towns)
        {
            if (Towns.Any())
            {
                throw new InvalidOperationException("Townsは既に初期化されています");
            }

            Towns = towns.ToList();
        }
        public TownsResponse Delete(Towns request)
        {
            Bm2s.Data.Common.BLL.Parameter.Town item = Datas.Instance.DataStorage.Towns[request.Town.Id];
              item.EndingDate = DateTime.Now;
              Datas.Instance.DataStorage.Towns[item.Id] = item;

              TownsResponse response = new TownsResponse();
              response.Towns.Add(request.Town);
              return response;
        }
Example #28
0
        /// <summary>
        /// Вернуть ID города по имени города
        /// </summary>
        /// <param name="s">Имя города</param>
        /// <returns>ID города</returns>
        private static int IdTownByName(string s)
        {
            Town t1 = Towns.Find(x => x.Name == s);

            if (t1 != null)
            {
                return(t1.Id);
            }
            return(-1);
        }
Example #29
0
        public void UpdateTown(Towns town)
        {
            var item = olympicGamesDBContext.Towns.Find(town.Id);

            if (item != null)
            {
                olympicGamesDBContext.Entry(item).CurrentValues.SetValues(town);
                olympicGamesDBContext.SaveChanges();
            }
        }
Example #30
0
 public ActionResult Edit([Bind(Include = "Id,Ilce")] Towns towns)
 {
     if (ModelState.IsValid)
     {
         db.Entry(towns).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(towns));
 }
Example #31
0
        void AddMinion()
        {
            Minions minions = new Minions();

            Console.Write("Enter minions name =");
            minions.Name = Console.ReadLine();

            Console.Write("Enter minions age =");
            minions.Age = Convert.ToInt32(Console.ReadLine());

            Towns towns = new Towns();

            Console.Write("Enter minions town =");
            towns.Name = Console.ReadLine();

            Villains villains = new Villains();

            Console.Write("Enter villains name =");
            villains.Name = Console.ReadLine();

            var checkVillainsName = from v in villainsRepository.GetAll()
                                    where v.Name.ToLower() == villains.Name.ToLower()
                                    select v.Name;

            int countVillains = checkVillainsName.Count();

            if (countVillains == 0)
            {
                villains.EvilnessFactorId = 4;
                villainsRepository.Insert(villains);
                Console.WriteLine($"Villain {villains.Name} was added to the database.");
            }

            var checkTownsName = from t in townsRepository.GetAll()
                                 where t.Name.ToLower() == towns.Name.ToLower()
                                 select t.Name;
            int countTowns = checkTownsName.Count();

            if (countTowns == 0)
            {
                towns.CountryCode = 4;
                townsRepository.Insert(towns);
                Console.WriteLine($"Town {towns.Name} was added to the database.");
            }

            foreach (var item in townsRepository.GetAll())
            {
                if (item.Name.ToLower() == towns.Name.ToLower())
                {
                    minions.TownId = item.Id;
                }
            }
            minionsRepositroy.Insert(minions);
            Console.WriteLine($"Successfully added {minions.Name} to be minion of {villains.Name}.");
        }
Example #32
0
        void Update()
        {
            Towns.Clear();
            var list = townsService.GetAsync().Result;

            foreach (var n in list)
            {
                Towns.Add(n);
            }
            MessengerInstance.Send(new ObservableCollection <TownsModel>());
        }
        public TownsResponse Get(Towns request)
        {
            TownsResponse response = new TownsResponse();
              List<Bm2s.Data.Common.BLL.Parameter.Town> items = new List<Data.Common.BLL.Parameter.Town>();
              if (!request.Ids.Any())
              {
            items.AddRange(Datas.Instance.DataStorage.Towns.Where(item =>
              (request.CountryId == 0 || item.CountryId == request.CountryId) &&
              (string.IsNullOrWhiteSpace(request.Name) || item.Name.ToLower().Contains(request.Name.ToLower())) &&
              (string.IsNullOrWhiteSpace(request.ZipCode) || item.ZipCode.ToLower().Contains(request.ZipCode.ToLower())) &&
              (!request.Date.HasValue || (request.Date >= item.StartingDate && (!item.EndingDate.HasValue || request.Date < item.EndingDate.Value)))
              ));
              }
              else
              {
            items.AddRange(Datas.Instance.DataStorage.Towns.Where(item => request.Ids.Contains(item.Id)));
              }

              var collection = (from item in items
                        select new Bm2s.Poco.Common.Parameter.Town()
                        {
                          Country = new CountriesService().Get(new Countries() { Ids = new List<int>() { item.CountryId } }).Countries.FirstOrDefault(),
                          EndingDate = item.EndingDate,
                          Id = item.Id,
                          Name = item.Name,
                          StartingDate = item.StartingDate,
                          ZipCode = item.ZipCode
                        }).AsQueryable().OrderBy(request.Order, !request.DescendingOrder);

              response.ItemsCount = collection.Count();
              if (request.PageSize > 0)
              {
            response.Towns.AddRange(collection.Skip((request.CurrentPage - 1) * request.PageSize).Take(request.PageSize));
              }
              else
              {
            response.Towns.AddRange(collection);
              }

              try
              {
            response.PagesCount = collection.Count() / response.Towns.Count + (collection.Count() % response.Towns.Count > 0 ? 1 : 0);
              }
              catch
              {
            response.PagesCount = 1;
              }

              return response;
        }