public async Task<ActionResult> UserProps(Cities city) {
     AppUser user = CurrentUser;
     user.City = city;
     user.SetCountryFromCity(city);
     await UserManager.UpdateAsync(user);
     return View(user);
 }
예제 #2
0
 /// <summary>
 /// Конструктор который задает параметры
 /// </summary>
 /// <param name="cityList"></param>
 /// <param name="bestTour"></param>
 /// <param name="generation"></param>
 /// <param name="complete"></param>
 public TspEventArgs(Cities cityList, Tour bestTour, int generation, bool complete)
 {
     this.cityList = cityList;
     this.bestTour = bestTour;
     this.generation = generation;
     this.complete = complete;
 }
예제 #3
0
 private void Initialize()
 {
     countries = new Countries(session);
     cities = new Cities(session);
     venues = new Venues(session);
     users = new Users(session);
     sports = new Sports(session);
     goals = new Goals(session);
 }
        public ActionResult In([Bind(Prefix = "id")] string city)
        {
            // http://localhost/endurancegoals/venues/in/madrid

            Cities cities = new Cities(SessionProvider.CurrentSession);

            var venueList = cities.GetByName(city).Venues;

            var jsonGoals = GetVenueList(venueList);

            return Json(jsonGoals, JsonRequestBehavior.AllowGet);
        }
예제 #5
0
 public void SetCountryFromCity(Cities city) {
     switch (city) {
         case Cities.LONDON:
             Country = Countries.UK;
             break;
         case Cities.PARIS:
             Country = Countries.FRANCE;
             break;
         case Cities.CHICAGO:
             Country = Countries.USA;
             break;
         default:
             Country = Countries.NONE;
             break;
     }
 }
        private void Initialize()
        {
            InitalizeSessionFactory(
                typeof (Country).Assembly,
                typeof (Goal).Assembly,
                typeof (User).Assembly,
                typeof (Venue).Assembly,
                typeof (Country).Assembly,
                typeof (Sport).Assembly);

            countries = new Countries(session);
            cities = new Cities(session);
            venues = new Venues(session);
            users = new Users(session);
            sports = new Sports(session);
            goals = new Goals(session);
            goalParticipants = new GoalParticipants(session);
        }
예제 #7
0
 public void SetCountryFromCity(Cities city)
 {
     switch (city)
     {
         case Cities.London:
             Country = Countries.UK;
             break;
         case Cities.Paris:
             Country = Countries.FRANCE;
             break;
         case Cities.Chicago:
             Country = Countries.USA;
             break;
         default:
             Country = Countries.None;
             break;
     }
 }
예제 #8
0
        public ResponseModel Update(Cities city)
        {
            ResponseModel result = new ResponseModel();

            try
            {
                city.CountryID = 1;
                _cityRepo.Update(city);
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                throw;
            }

            result.IsSuccess = true;
            result.Message   = "Güncelleme işlemi başarılı.";
            return(result);
        }
예제 #9
0
    public bool SpawnCityAt(City city, GameObject prefab, int q, int r)
    {
        Hex[] hs = GetHexesInRadius(GetHexAt(q, r), 4);
        foreach (Hex h in hs)
        {
            if (h.city != null)
            {
                return(false);
            }
        }
        GetHexAt(q, r).city = city;
        city.Hex            = GetHexAt(q, r);

        if (city.Hex.Biome == Hex.HexBiome.Forest || city.Hex.Biome == Hex.HexBiome.Jungle)
        {
            city.Hex.Biome    = Hex.HexBiome.Grassland;
            city.Hex.Moisture = MoistureGrassland;
            UpdateHexVisuals();
        }

        GameObject CityGO = GameObject.Instantiate(prefab, HexToGo[city.Hex].transform);

        if (city.Hex.Type == Hex.HexType.Hill)
        {
            Vector3 pos = CityGO.transform.position;
            pos.y += .2f;
            CityGO.transform.position = pos;
        }

        CityGO.name = city.Name + " " + city.Hex;
        city.Buildings.Add(BuildingTypes["Palace"]);
        CityToGo.Add(city, CityGO);
        Cities.Add(city);
        CityGO.GetComponent <CityView>().City = city;
        city.hexes = GetHexesInRadius(city.Hex, 2).ToList();
        UpdateFogOfWar(new Unit("", GetHexAt(q, r))
        {
            Vision = 4
        });


        return(true);
    }
        public void Main()
        {
            //Retrieves all the cities from the json file.
            List <City> citiesGroup = Cities.Get();

            bool keyCityCheck = false;

            // Checks for a key city.
            foreach (Cities.City singleCity in citiesGroup)
            {
                if (singleCity.Name.ToLower() == "darlington")
                {
                    keyCityCheck = true;
                    break;
                }
            }

            Assert.AreEqual(keyCityCheck, true);
        }
예제 #11
0
    private void RebuildFromPostalCode()
    {
        Cities citiylist = Cities.FromPostalCode(TextPostal.Text, DropCountries.SelectedValue);

        LabelPostalErrorUnknown.Visible = false;
        string selectedKommun = DropDownKommun.SelectedValue;

        DropDownKommun.Items.Clear();
        foreach (City city in citiylist)
        {
            TextCity.Text = city.Name;
            ListItem newItem = new ListItem(city.Geography.Name, city.Geography.GeographyId.ToString());
            DropDownKommun.Items.Add(newItem);
            if (selectedKommun == city.Geography.GeographyId.ToString())
            {
                newItem.Selected = true;
            }
        }
        if (citiylist.Count > 1)
        {
            LabelKommun.Visible      = true;
            DropDownKommun.Visible   = true;
            LabelKommunError.Visible = true;
        }
        else
        {
            LabelKommun.Visible      = false;
            DropDownKommun.Visible   = false;
            LabelKommunError.Visible = false;
        }

        if (citiylist.Count == 0)
        {
            LabelPostalErrorUnknown.Visible = true;
        }
        else
        {
            if (DropDownKommun.SelectedIndex < 0)
            {
                DropDownKommun.SelectedIndex = 0;
            }
        }
    }
예제 #12
0
        public async Task GetPickerValues()
        {
            var countriesList = await CountryDataStore.GetItemsAsync();

            foreach (Country c in countriesList)
            {
                Countries.Add(c);
            }

            SelectedCountry = Countries.First(x => x.Id == Model.Country.Id);


            var citiesList = await CityDataStore.GetItemsAsync();

            foreach (var item in citiesList)
            {
                Cities.Add(item);
            }

            SelectedCity = Cities.First(x => x.Id == Model.City.Id);


            var seasonsList = await SeasonDataStore.GetItemsAsync();

            foreach (var item in seasonsList)
            {
                Seasons.Add(item);
            }

            SelectedSeason = Seasons.First(x => x.Id == Model.Season.Id);


            var currenciesList = await CurrencyDataStore.GetItemsAsync();

            foreach (var item in currenciesList)
            {
                Currencies.Add(item);
            }

            SelectedCurrency = Currencies.First(x => x.Id == Model.Currency.Id);

            IsBusy = false;
        }
예제 #13
0
        public JsonResult Add(string cityName, string cityKey, string countryCode)
        {
            var checkDuplicate = Cities.SingleOrDefault(_ => _.Name.Equals(cityName, OrdinalIgnoreCase));

            if (checkDuplicate != null)
            {
                return(Json(ObjectError($"{cityName} city is already attached."), AllowGet));
            }

            var city = new City
            {
                Name        = cityName,
                Key         = cityKey,
                CountryCode = countryCode
            };

            Cities.Add(city);
            return(Json(ObjectSuccess(city, "The new city has been successfully added.", null), AllowGet));
        }
예제 #14
0
        public JsonResult addOrEditCity(Cities city)
        {
            ResponseModel result = new ResponseModel();

            if (string.IsNullOrEmpty(city.Uri))
            {
                city.Uri = _postM.GenerateUriFormat(city.Name);
            }

            if (city.ID <= 0)
            {
                result = _cityM.AddCity(city);
            }
            else
            {
                result = _cityM.Update(city);
            }
            return(Json(result));
        }
예제 #15
0
        public ResponseModel AddCity(Cities city)
        {
            ResponseModel result = new ResponseModel();

            try
            {
                city.CountryID = 1;
                city.ID        = _cityRepo.Insert(city);
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                throw;
            }

            result.IsSuccess = true;
            result.Message   = "Kaydetme işlemi başarılı.";
            return(result);
        }
예제 #16
0
        public static SettingsModel Get()
        {
            var s = new SettingsModel();

            s.Cities      = Cities.Get();
            s.Immersive   = Immersive.Get();
            s.Preferences = Preferences.Get();
            var init = LocalSettingsHelper.ReadSettingsValue("Inited");

            if (init == null)
            {
                s.Inited = false;
            }
            else
            {
                s.Inited = true;
            }
            return(s);
        }
예제 #17
0
        internal override void SelectAll()
        {
            ClearData();
            this.ExecuteCommand(SELECT_ALL_FROM_TABLE, "CITIES");
            this.dataReader = this.Statement.ExecuteReader();
            Cities temp;

            while (dataReader.Read())
            {
                temp = new Cities(
                    dataReader.GetValue(0),
                    dataReader.GetValue(1),
                    dataReader.GetValue(2),
                    dataReader.GetValue(3)
                    );
                this.CitiesList.Add(temp);
            }
            CloseDatabaseConnection();
        }
 private static void ValidateCity(Cities city)
 {
     if (city.Cases < 0 || city.TodayCases < 0 || city.Latitude <= 0 || city.Longitude <= 0)
     {
         throw new FlowException("Внесовте невалиден формат!");
     }
     else if (city.Latitude.ToString().IndexOf(".") > 2 || city.Longitude.ToString().IndexOf(".") > 2)
     {
         throw new FlowException("Внесовте невалиден формат!");
     }
     else if (city.Latitude.ToString().Length < 9 || city.Longitude.ToString().Length < 9)
     {
         throw new FlowException("Внесовте невалиден формат!");
     }
     else if (city.City == null || city.Cases == null || city.TodayCases == null || city.Latitude == null || city.Longitude == null)
     {
         throw new FlowException("Ве молиме пополнете ги сите полиња!");
     }
 }
예제 #19
0
  public static List<Cities>MyCities()
  {
   var c1 = new Cities{ CityId = 1, City= "Antwerp", CountryId = 1};
   var c2 = new Cities{ CityId = 2, City= "Den Haag", CountryId = 2};
   var c3 = new Cities{ CityId = 3, City= "Brussels", CountryId = 1};
   var c4 = new Cities{ CityId = 4, City= "Rotterdam", CountryId = 2};
   var c5 = new Cities{ CityId = 5, City= "Amsterdam", CountryId = 2};
   var c6 = new Cities{ CityId = 6, City= "Hasselt", CountryId = 1};
 
   var result= new List<Cities>();
   result.Add(c1);
   result.Add(c2);
   result.Add(c3);
   result.Add(c4);
   result.Add(c5);
   result.Add(c6);
  
   return result;
  }
예제 #20
0
        public void TestTask5_CompareParallelSequential()
        {
            Cities cities = new Cities();

            cities.ReadCities(@"citiesTestDataLab11.txt");
            Assert.AreEqual(6372, cities.Count);

            Routes routes = new RoutesFloydWarshall(cities);

            routes.ExecuteParallel = true;
            long floydWarshallParallelTime = FindRoutes(routes);

            routes = new RoutesFloydWarshall(cities);
            routes.ExecuteParallel = false;
            long floydWarshallTime = FindRoutes(routes);

            // the sequentiel floydWarshal should be slower
            Assert.IsTrue(floydWarshallTime > floydWarshallParallelTime, "FloydWarshal parallel should be faster than sequential");
        }
예제 #21
0
        /// <summary> Ustawienie kontrolek widoku na podstawie wartości pól edytowanego elementu </summary>
        private void LoadData(Cities entity)
        {
            try
            {
                if (entity.postalCode != null)
                {
                    this.PostalCodeTextBoxContent = entity.postalCode;
                }
                else
                {
                    this.PostalCodeTextBoxContent = "";
                }
                if (entity.name != null)
                {
                    this.CityNameTextBoxContent = entity.name;
                }
                else
                {
                    this.CityNameTextBoxContent = "";
                }

                if (entity.dateOfCreation != null)
                {
                    this.DateOfCreation = Convert.ToDateTime(entity.dateOfCreation);
                }
                else
                {
                    this.DateOfCreation = DateTime.Now.ToLocalTime();
                }
                if (entity.dateOfUpdate != null)
                {
                    this.DateOfUpdate = Convert.ToDateTime(entity.dateOfUpdate);
                }
                else
                {
                    this.DateOfUpdate = DateTime.Now.ToLocalTime();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public void SetCountryFromCity(Cities city)
 {
     switch (city)
     {
         case Cities.Shanghai:
         case Cities.Hangzhou:
             Country=Countries.China;
             break;
         case Cities.NewYork:
             Country=Countries.USA;
             break;
           case Cities.Tokyo:
             Country=Countries.Japan;
             break;
         default:
             Country=Countries.None;
             break;
     }
 }
예제 #23
0
        public async Task <ActionResult <Cities> > PostCities(Cities cities)
        {
            route          = Request.Path.Value;
            method         = Request.Method;
            remember_token = HttpContext.Request.Headers["Authorization"];
            token          = new JwtSecurityTokenHandler().ReadJwtToken(remember_token);
            idUser         = token.Claims.First(claim => claim.Type == "id").Value;

            if (_context.PermissionDetails.Any(pd => pd.UsersId == int.Parse(idUser) &&
                                               pd.permalink_permissions == route && pd.action == method))
            {
                _citiesRepository.CreateCities(cities);
                return(NoContent());
            }
            else
            {
                return(StatusCode(203));
            }
        }
예제 #24
0
 public CitiesPageViewModel()
 {
     Theme = settings.Preferences.GetTheme();
     if (settings.Cities.EnableLocate)
     {
         if (settings.Cities.LocatedCity != null)
         {
             Cities.Add(new CityViewModel(settings.Cities.LocatedCity, true));
         }
     }
     foreach (var city in settings.Cities.SavedCities)
     {
         Cities.Add(new CityViewModel(city, false));
     }
     Cities.Add(new CityViewModel());
     if (Cities.IsNullorEmpty())
     {
         var t = ThreadPool.RunAsync(async(work) =>
         {
             await Task.Delay(1000);
             this.OnFetchDataFailed();
         });
         return;
     }
     var task = ThreadPool.RunAsync(async(work) =>
     {
         var ask = ThreadPool.RunAsync(async(m) =>
         {
             await SearchExistingDataAsync();
             EnableLocate = settings.Cities.EnableLocate;
             RequireLocationUpdate();
         });
         await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, new DispatchedHandler(async() =>
         {
             await Init();
             var t = ThreadPool.RunAsync((x) =>
             {
                 Update();
             });
         }));
     });
 }
예제 #25
0
        public static void Seed(IApplicationBuilder applicationBuilder)
        {
            ApplicationDbContext context =
                applicationBuilder.ApplicationServices.GetRequiredService <ApplicationDbContext>();

            if (!context.Categories.Any())
            {
                context.Categories.AddRange(Categories.Select(c => c.Value));
            }

            if (!context.Cities.Any())
            {
                context.Cities.AddRange(Cities.Select(c => c.Value));
            }
            //if (!context.Roles.Any())
            //{
            //    IdentityRole role = new IdentityRole();
            //    role.Name = "Admin";
            //    context.Roles.Add(role);
            //}

            //if (!context.Properties.Any())
            //{
            //    context.AddRange
            //    (
            //        //courses.Single(c => c.Title == "Chemistry").CourseID
            //        //new Property { Customer = Customers.Single(c => c.Value.FirstName == "Ana").Value, CustomerId = 0, City = Cities.Single(c => c.Value.CityName == "Beograd").Value, CityId = Cities.Single(c => c.Value.CityName == "Beograd").Value.CityId, Price = 70000, ShortDescription = "Kuca sa velikim dvorištem", LongDescription = "Kuca sa velikim dvorištem, u kojem se nalazi bašta i bazen", Category = Categories.Single(c => c.Value.CategoryName == "Kuca").Value, CategoryId = Categories.Single(c => c.Value.CategoryName == "Kuca").Value.CategoryId, ImageUrl = "https://7wuxfa.bn.files.1drv.com/y4m9JeLv8HRYThlF6d2538eRN2Mb2YLSgd__1mgxRM4AUEZ_7HohngLlc8ahyt5VKhwKexiX6ISfpQ_zXNs-lzmrjIEuar0CsLSwsCWrtG-GsnkDu2stdJY75OX3P72K36zdpRObn0edPV2NLeO5Y-aOTvKoglAfeQZH8xxddErDR-UjaLdCI49Bt4Ji5mnnyDQvjmensP06-MSP4vbTDrsYA?width=1197&height=682&cropmode=none", Address = "Novosadski put 11", Date = DateTime.Now, Area = 90, Baths = 2, Rooms = 5, Email = false, PhoneNumber = false, PropertyId = 0 }
            //        //new Property { City = Cities["Beograd"], Price = 20000, ShortDescription = "Poljoprivredno zemljište", LongDescription = "Poljoprivredno zemljište", Category = Categories["Poljoprivredno zemljište"], ImageUrl = "https://inpe8q.bn.files.1drv.com/y4mvBC8nKF3x_AFn30JJSoi1U_PiMoB3tcRFIYOUe5uwgYDNNyl9yWHDtrxYFa26yHj0RxVyfpycJPqwL-ObBeF1IAeiw4x7r9Xowp3sm-om__znDv6XSCkm2F6zYh7XozP98OvfITHCNfn3YUhC8oUZWUWj6u65BAwOxz1sRlVLDxLE5pWpTKlWLyHKIkcdA_2Vzi_-YAvwXTjAVDQuwty3A?width=800&height=533&cropmode=none", Address = "Futoški put 11", Date = DateTime.Now, Area = 1000, Email = false, PhoneNumber = false }
            //        //new Property { City = Cities["Niš"], Price = 40000, ShortDescription = "Stan na cetvrtom spratu u novoj zgradi", LongDescription = "Stan na cetvrtom spratu u novoj zgradi", Category = Categories["Stan"], ImageUrl = "https://7wwdtg.bn.files.1drv.com/y4mzaK3oWBOJq02Is03PTYMJ_TXco1NeRN9vr0ADVpKOP9tZMWLVe8tBBky-GTcynN1S4hj2cT9HJaaL32iu36XIfINybu_VM7E6IkrrQk9n0CqkYTBJVf31hbCTPZSqooc9-KJiAVrmfbuWOF_Zw-wUQS_JhQlrphrC-Co4KwnSayTcd4COpxFT3WgXkWR0jH6DjjmQNMK81fXsgivm2gIYA?width=720&height=405&cropmode=none", Address = "Cirpanova 85", Date = DateTime.Now, Area = 70, Baths = 1, Rooms = 3, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Pirot"], Price = 15000, ShortDescription = "Prelep pogled na reku", LongDescription = "Vikendica se nalazi u prelepoj prirodi.", Category = Categories["Vikendica"], ImageUrl = "https://inrfzq.bn.files.1drv.com/y4mKghZds7VvdV09lyYcHRbQEkaEYjC4Ouz6zj8nm3pAwoptBk1uwOL8cQ0J76TGpCsBu5IqbbWlIA2D2lOh0FHU1MrD7pX6-3o2oZ9P_aYTYAdvaEjnAdiu81Np_4iOmDoFQFxqtERV7J7a9R8bWVJrg_ghitzzKWupyj7xhwwc-tqLqcnHQcCgaj3jrs3eV5aJmP1AWez9OyFEw-uJRXh3Q?width=800&height=533&cropmode=none", Address = "Bulevar Cara Dušana 3", Date = DateTime.Now, Area = 50, Baths = 1, Rooms = 1, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Novi Sad"], Price = 5000, ShortDescription = "Višenamenski pomocni objekat", LongDescription = "Višenamenski pomocni objekat", Category = Categories["Pomocni objekat"], ImageUrl = "https://inploa.bn.files.1drv.com/y4myzQCuKAudKDUzb6LDkLOIsZbCJ4j1ZBcazPVJfgKoxdPnVLkSyp_LMCPw7Ib4pS0NZIqB3bhSLB9a3dvRN-Uty0Tmi006S85ZjjOu2AURDZP9Gm6j7nlXGhJ8GHL60RCzfl-DrwmjjTNdUNp2Zq0EBDvYlZmBx65VC8e6tH9yODJeSpq_KxbF5vUa3aGQlMhdRZhfb3Yx7hGWPoUL2-SGQ?width=1024&height=768&cropmode=none", Address = "Bulevar Oslobodenja 21", Date = DateTime.Now, Area = 300, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Subotica"], Price = 100000, ShortDescription = "Lokal se nalazi u samom centru grada", LongDescription = "Lokal se nalazi u samom centru grada", Category = Categories["Poslovni prostor"], ImageUrl = "https://inqwww.bn.files.1drv.com/y4mtOVM3R-Q5C_cf6mAbXFg5ugge6D7P-AfJvM9uxm1vCuUOfSriomurpSUGrURXgE7IJr3ID9pRemnz-0cPrKdv60xTfbaNDohjAjBGHyca2SrkDfLEj6znPK8DVhb4izdjvfBiOleXpRc_2wNcI1OCtVW_qwXXH_9e-RZtujeHlkaHCfny-h7hMtxDuULfKe32hW5b9XMKJeceTpyBrbxaw?width=500&height=332&cropmode=none", Address = "Novosadski put 18", Date = DateTime.Now, Area = 100, Baths = 1, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Jagodina"], Price = 250000, ShortDescription = "Sportski objekat", LongDescription = "Sportski objekat", Category = Categories["Sportski objekat"], ImageUrl = "https://inp62g.bn.files.1drv.com/y4mahdWZhsd118d5kgbGG_PQ1qzlOh4Ev9g1OKno5F6SlSj8gzmEYozypSFECmJQ8dDaPDdxfiWFjDnRKXPcnx03NiyhkoBz7hO823ljExLvnANevLQ5HODWLvVWwSEuf1tBj8LXWcNYbAc0ZJgijfAxYcYm74yrTs0OF94CqdeU4hwdGaFZ9_5twCsIcPaZ8_ZO6FuVyPxZ5VLzVCIxwikdA?width=900&height=599&cropmode=none", Address = "Novosadski put 1", Date = DateTime.Now, Area = 800, Baths = 7, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Beograd"], Price = 30000, ShortDescription = "Plac spreman za gradnju", LongDescription = "Zemljište spreman za gradnju", Category = Categories["Gradevinsko zemljište"], ImageUrl = "https://inovtw.bn.files.1drv.com/y4mxTNHx9wGZiriXOTidqlbYBPKZOyx3O4sgrWQ0-Nk9560juKIIsZZjhb59TFnfNvDJ2ckeexL2kScmO1iwGdKsfStuCfQYRFCBixZ_Y3fnVlXVTXs2ZXsAyTe1NzVQRBvh9HAzZ1QsgBYJDbxybCOhVFaU04ibZ4UNS9kPoPQ6jnD6hCUKudqAsrg3u7Bp510iy4KC6b0HJ99IqvPwtHGLg?width=620&height=348&cropmode=none", Address = "Futoška 19", Date = DateTime.Now, Area = 100, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Beograd"], Price = 150000, ShortDescription = "Kuca sa dve garaže", LongDescription = "Kuca sa dve garaže", Category = Categories["Kuca"], ImageUrl = "https://7wxm8a.bn.files.1drv.com/y4mp7yNdOd-arDcOMJ5Qv1grondFE3codPe_mZFEARUvLuJmofFz2Jeocubh3Q7qM_uAPJ9YbUlsrACTyJcVNz_Ho2Ay-OOaW-Y4LcF0ZnXyrDlvW3K3dMULRVYFfzjLonO3YTzSIATUeGp_OpSjkSpbE_-TpFLT-rAtvsJlrJhKvt3YzMD4ZQX7zbHXmjs-_vUfUmlARl0bdSxBiHjAo62uw?width=1920&height=1280&cropmode=none", Address = "Kneginja Milica 21", Date = DateTime.Now, Area = 300, Baths = 3, Rooms = 5, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Vranje"], Price = 35000, ShortDescription = "Prekrasan stan sa svojim parkingom", LongDescription = "Dvosoban stan sa parkingom. 54 kvadratnih metara s pokrivenom terasom. Stan ima centralno grejanje.", Category = Categories["Stan"], ImageUrl = "https://inqpfa.bn.files.1drv.com/y4m1PqSMq24hX6RPPMg7O4GQj9cu8iFYmR_ZxrqlgeOv7FoiPCTtfz9480y8rKxcJCF1eZcpnx3cP-1VKpjppdAgoA1H62CzfxPdj-XgmEf47uOCwi4CZJe0JT7eA8EHuK_TwljdB4lyT3ogSi8s7HgJVKcGL8v56eTPmaQQZDYCNI0pBQeRaINwAsnOaK_bFkdf0DFk5BEYrxEfTJciwt99Q?width=640&height=425&cropmode=none", Address = "Futoška 25", Date = DateTime.Now, Area = 54, Baths = 1, Rooms = 2, Email = false, PhoneNumber = false },
            //        //new Property { City = Cities["Kragujevac"], Price = 65000, ShortDescription = "Kuca u Kragujevcu", LongDescription = "Kuca u Kragujevcu", Category = Categories["Kuca"], ImageUrl = "https://7wvnzq.bn.files.1drv.com/y4mbfuVIyKmnQR4afEslOibHMhx7tyD2fbUULfOS99PVVd1PN5RCcp_NJXjaLKOQ1KS5Y7DGnEirrCfREfj9mlLfJeyXJr3zThRiTKywl2miR4shaFntmZszusLkSkeAX_mdaZrrn-_ZdXm8EGN9Y6OrNPKi9sezNsMkTA2CuKsUBS_Tb4mnwat9-v1A549N6TvJj483wnYG8xOKthiTFjELg?width=1280&height=720&cropmode=none", Address = "Novosadski put 51", Date = DateTime.Now, Area = 100, Baths = 2, Rooms = 4, Email = false, PhoneNumber = false }
            //    );
            //}

            context.SaveChanges();
        }
예제 #26
0
        public List <Cities> GetCities(int ID)
        {
            List <Cities> CityList = new List <Cities>();

            using (var Con = new SqlConnection(GC.ConnectionString))
            {
                Con.Open();

                Querry = "Select * from GeographyArea where Parent_id='" + ID + "'";

                using (var Com = new SqlCommand(Querry, Con))
                {
                    Reader = Com.ExecuteReader();

                    while (Reader.Read())
                    {
                        Cities City = new Cities();

                        City.ID = Convert.ToInt32(Reader["Geo_Area_Id"].ToString());

                        City.Name = Reader["Geo_Name"].ToString();

                        if (Reader["Parent_id"] == DBNull.Value)
                        {
                        }
                        else
                        {
                            City.ParentId = Convert.ToInt32(Reader["Parent_id"].ToString());
                        }


                        CityList.Add(City);
                    }

                    Com.Dispose();
                }

                Con.Close();
            }

            return(CityList);
        }
예제 #27
0
//------------------------------------------- USERS ------------------------------------------
        public bool CreateUser(User user)
        {
            // Adding a new row in the database table Users for this User:
            var newUser = new Users()
            {
                FirstName   = user.firstName,
                LastName    = user.lastName,
                Address     = user.address,
                Email       = user.email,
                PhoneNumber = user.phoneNumber,
                PostalCode  = user.postalCode,
                UserName    = user.userName,
                Password    = CreateHash(user.password)
            };

            var db = new DBContext();

            try
            {
                var postalCodeExists = db.Cities.Find(user.postalCode);

                // We also need to add the user's city in the database if it doesn't exist:
                if (postalCodeExists == null)
                {
                    var newCity = new Cities()
                    {
                        PostalCode = user.postalCode,
                        City       = user.city
                    };
                    newUser.City = newCity;
                }

                // Adding the new Users-row in the database:
                db.Users.Add(newUser);
                db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #28
0
        public void TestIndexer()
        {
            var cities = new Cities();

            // we call the overwritten method of the mock class
            cities.AddCity(new City("Bern", "Schweiz", 75000, 47.4793198, 8.2129669189));
            cities.AddCity(new City("Zurich", "Schweiz", 375000, 47.4793198, 8.2129669189));
            cities.AddCity(new City("Aarau", "Schweiz", 25000, 47.4793198, 8.2129669189));

            Assert.AreEqual("Bern", cities[0].Name);
            Assert.AreEqual("Zurich", cities[1].Name);
            Assert.AreEqual("Aarau", cities[2].Name);

            // check for invalid index
            try
            {
                var c = cities[-1];
                Assert.Fail("Invalid index not handled properly");
            }
            catch (ArgumentOutOfRangeException _iore)
            {
                Assert.IsTrue(_iore.Message.Length > 2, "IndexOutOfRangeException has no meaningful description");
            }
            catch
            {
                Assert.Fail("Wrong exception type thrown on invalid index");
            }

            try
            {
                var c = cities[100];
                Assert.Fail("Invalid index not handled properly");
            }
            catch (ArgumentOutOfRangeException _iore)
            {
                Assert.IsTrue(_iore.Message.Length > 2, "IndexOutOfRangeException has no meaningful description");
            }
            catch
            {
                Assert.Fail("Wrong exception type thrown on invalid index");
            }
        }
예제 #29
0
        public async Task <IActionResult> PutCities(int id, Cities cities)
        {
            if (id != cities.id)
            {
                return(BadRequest());
            }

            route = Request.Path.Value;
            //Console.WriteLine(route.);
            method         = Request.Method;
            remember_token = HttpContext.Request.Headers["Authorization"];
            token          = new JwtSecurityTokenHandler().ReadJwtToken(remember_token);
            idUser         = token.Claims.First(claim => claim.Type == "id").Value;

            if (_context.PermissionDetails.Any(pd => pd.UsersId == int.Parse(idUser) &&
                                               route.StartsWith(pd.permalink_permissions) && pd.action == method))
            {
                _citiesRepository.UpdateCities(id, cities);
                return(NoContent());
            }
            else
            {
                return(StatusCode(203));
            }


            //var result = from p in _context.PermissionDetails
            //             where p.isDeleted == false && p.UsersId == int.Parse(idUser) &&
            //            route.StartsWith(p.permalink_permissions) && p.action == method
            //             select new
            //             {
            //                 p.id
            //             };
            ////Console.WriteLine()
            //if (result.Count() > 0)
            //{
            //    _citiesRepository.UpdateCities(id, cities);
            //    return NoContent();
            //}
            //else
            //    return StatusCode(203);
        }
예제 #30
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                if (!lastRun.HasValue || (lastRun.HasValue && !lastRun.Value.Equals(DateTime.Now.Date)))
                {
                    lastRun = DateTime.Now.Date;

                    _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);

                    CsvRow newRow = new CsvRow();
                    newRow.Date = DateTime.Now.Date.ToString("dd.MM.yyyy");

                    string path       = _env.ContentRootPath;
                    string olxRentCsv = $"{path}/olxData.csv";

                    List <CsvRow> records = _localCSVHelper.ReadCSVOldData(olxRentCsv);

                    if (!records.Any(x => x.Date == newRow.Date))
                    {
                        foreach (var city in Cities.GetCities())
                        {
                            try
                            {
                                (int rentCount, int sellCount) = ReadDataFromOlx(city);
                                newRow = GetNewRowData(newRow, city, rentCount, sellCount);
                            }
                            catch (Exception ex)
                            {
                                _logger.LogInformation(ex.Message, DateTimeOffset.Now);
                            }
                        }

                        _localCSVHelper.SaveCSVData(records, newRow, olxRentCsv);
                    }
                }

                int delay = 1000 * 60 * 60 * 1; //1h

                await Task.Delay(delay, stoppingToken);
            }
        }
예제 #31
0
        public void TestRequestWatcher()
        {
            var reqWatch = new RouteRequestWatcher();

            var cities = new Cities();

            cities.ReadCities(CitiesTestFile);

            var routes = new RoutesDijkstra(cities);

            routes.RouteRequestEvent += reqWatch.LogRouteRequests;

            routes.FindShortestRouteBetween("Bern", "Zürich", TransportModes.Rail);
            routes.FindShortestRouteBetween("Bern", "Zürich", TransportModes.Rail);
            routes.FindShortestRouteBetween("Basel", "Bern", TransportModes.Rail);

            Assert.AreEqual(reqWatch.GetCityRequests("Zürich"), 2);
            Assert.AreEqual(reqWatch.GetCityRequests("Bern"), 1);
            Assert.AreEqual(reqWatch.GetCityRequests("Basel"), 0);
        }
예제 #32
0
        public void TestCorrectIndexingOfCities()
        {
            const int readCitiesExpected = 10;
            var       cities             = new Cities();

            Assert.AreEqual(readCitiesExpected, cities.ReadCities(CitiesTestFile));;;

            City        from        = cities.FindCity("Mumbai");
            City        to          = cities.FindCity("Istanbul");
            List <City> foundCities = cities.FindCitiesBetween(from, to);

            // verify that Index property is initialized
            int i = 0;

            foreach (var city in foundCities)
            {
                Assert.AreEqual(i, city.Index);
                i++;
            }
        }
        public EmployeeAccountModel()
        {
            BasicRepository _basic = new BasicRepository();

            BasicContants.StoredProcedure = "GetAdminRoles";
            Roles    = _basic.Get();
            RoleList = Roles.ToRoleSelectListItems(RoleID);

            BasicContants.StoredProcedure = "GetGender";
            Genders    = _basic.Get();
            GenderList = Genders.ToGenderSelectListItems(GenderID);

            BasicContants.StoredProcedure = "GetCity";
            Cities   = _basic.Get();
            CityList = Cities.ToCitySelectListItems(CityID);

            BasicContants.StoredProcedure = "GetDesignation";
            Designations    = _basic.Get();
            DesignationList = Designations.ToDesignationSelectListItems(DesignationID);
        }
예제 #34
0
        public void TestTaskReadRoutes()
        {
            var cities = new Cities();

            cities.ReadCities(CitiesTestFile);
            var expectedLinks = new List <Link>();

            expectedLinks.Add(new Link(new City("Zürich", "Switzerland", 7000, 1, 2),
                                       new City("Aarau", "Switzerland", 7000, 1, 2), 0));
            expectedLinks.Add(new Link(new City("Aarau", "Switzerland", 7000, 1, 2),
                                       new City("Liestal", "Switzerland", 7000, 1, 2), 0));
            expectedLinks.Add(new Link(new City("Liestal", "Switzerland", 7000, 1, 2),
                                       new City("Basel", "Switzerland", 7000, 1, 2), 0));

            var routes = new RoutesDijkstra(cities);
            var count  = routes.ReadRoutes(LinksTestFile);

            Assert.AreEqual(10, count);
            Assert.AreEqual(10, routes.Count);
        }
예제 #35
0
        public static List <City> GetAll()
        {
            List <City> lstCities = new List <City>();
            DataTable   table     = Cities.GetAll();

            if (table != null && table.Rows.Count > 0)
            {
                foreach (DataRow myRow in table.Rows)
                {
                    City city = new City(Convert.ToInt32(myRow["Id"].ToString()), myRow["Name"].ToString());
                    lstCities.Add(city);
                }

                return(lstCities);
            }
            else
            {
                return(null);
            }
        }
예제 #36
0
        public void TestFindNeighboursSorted()
        {
            var cities = new Cities();

            cities.ReadCities(citiesTestFile);

            var loc = cities[0].Location;

            var neighbors = cities.FindNeighboursSorted(loc, 2000).ToArray();

            //verify the correct order (sorted  by distance)
            Assert.AreEqual(4, neighbors.Length);
            Assert.AreEqual("Mumbai", neighbors[0].Name);
            Assert.AreEqual("Karachi", neighbors[1].Name);
            Assert.IsTrue(loc.Distance(neighbors[0].Location) <= loc.Distance(neighbors[1].Location));
            Assert.AreEqual("Dilli", neighbors[2].Name);
            Assert.IsTrue(loc.Distance(neighbors[1].Location) <= loc.Distance(neighbors[2].Location));
            Assert.AreEqual("Dhaka", neighbors[3].Name);
            Assert.IsTrue(loc.Distance(neighbors[2].Location) <= loc.Distance(neighbors[3].Location));
        }
예제 #37
0
        public IActionResult ShowCategories(ProductsEnum category, Cities city, string keySearch)
        {
            //if (keySearch == null)
            //{
            //    return Content("Не е намерен артикул с тази ключава дума");
            //}

            if (keySearch != null)
            {
                var ordered = ShowAllProductsWithCategory(category, city, keySearch)
                              .OrderByDescending(c => c.Date);

                if (ordered.Count() <= 0)
                {
                    return(View("Views/Home/NotFoundSearch.cshtml"));
                }
                return(View(ordered));
            }
            return(View(ShowAllProductsWithCategory(category, city, keySearch)));
        }
예제 #38
0
        public async Task QuerySubmitted(object args)
        {
            if (((AutoSuggestBoxQuerySubmittedEventArgs)args).ChosenSuggestion != null)
            {
                //User selected an item, take an action
                Location = ((AutoSuggestBoxQuerySubmittedEventArgs)args).QueryText;
                // await add();
            }
            else if (!string.IsNullOrEmpty(((AutoSuggestBoxQuerySubmittedEventArgs)args).QueryText))
            {
                //Do a fuzzy search based on the text
                Cities.Clear();
                var suggestions = GeonameRootData = await requestCity((AutoSuggestBoxText));

                foreach (var item in suggestions.geonames)
                {
                    Cities.Add(item.name);
                }
            }
        }
예제 #39
0
파일: World.cs 프로젝트: Lesrac/ecnf_labor
 public World(Cities cities) : base()
 {
     this.cities = cities;
 }
예제 #40
0
 // Code to execute when the application is launching (eg, from Start)
 // This code will not execute when the application is reactivated
 private void Application_Launching(object sender, LaunchingEventArgs e)
 {
     // if our list of cities is empty, create the list
     if (null == cityList)
     {
         cityList = new Cities();
         cityList.LoadDefaultData();
     }
 }
예제 #41
0
파일: World.cs 프로젝트: Laubeee/ecnf
 public World(Cities _cities)
 {
     cities = _cities;
 }
예제 #42
0
파일: World.cs 프로젝트: mjenny/ECNF
 public World(Cities cities)
 {
     _cities = cities;
 }
예제 #43
0
        /// <summary>
        /// ������ ������ �������.
        /// </summary>
        /// <param name="cityList">������ ������� ��� ���������.</param>
        private void DrawCityList(Cities cityList)
        {
            Image cityImage = new Bitmap(tourDiagram.Width, tourDiagram.Height);
            Graphics graphics = Graphics.FromImage(cityImage);

            foreach (City city in cityList)
            {
                graphics.DrawEllipse(Pens.Black, city.Location.X - 2, city.Location.Y - 2, 5, 5);
            }

            this.tourDiagram.Image = cityImage;

            updateCityCount();
        }
 public void SomeAction(Cities city) {}
예제 #45
0
 public World(Cities cities)
 {
     this._cities = cities;
 }
예제 #46
0
        /// <summary>
        /// <see cref="Halt"/> 
        /// </summary>
        /// <param name="populationSize">рандом</param>
        /// <param name="maxGenerations">Кроссовер</param>
        /// <param name="groupSize">Выбор родителей и создание детей</param>
        /// <param name="mutation">Мутации</param>
        /// <param name="seed">Розсеивание</param>
        /// <param name="chanceToUseCloseCity">Ближайший город</param>
        /// <param name="cityList">Список городов.</param>
        public void Begin(int populationSize, int maxGenerations, int groupSize, int mutation, int seed, int chanceToUseCloseCity, Cities cityList)
        {
            rand = new Random(seed);

            this.cityList = cityList;

            population = new Population();
            population.CreateRandomPopulation(populationSize, cityList, rand, chanceToUseCloseCity);

            displayTour(population.BestTour, 0, false);

            bool foundNewBestTour = false;
            int generation;
            for (generation = 0; generation < maxGenerations; generation++)
            {
                if (Halt)
                {
                    break;
                }
                foundNewBestTour = makeChildren(groupSize, mutation);

                if (foundNewBestTour)
                {
                    displayTour(population.BestTour, generation, false);
                }
            }

            displayTour(population.BestTour, generation, true);
        }
예제 #47
0
 public World(Cities c)
 {
     this.cities = c;
 }
 /// <summary>
 /// There are no comments for Cities in the schema.
 /// </summary>
 public void AddToCities(Cities cities)
 {
     base.AddObject("Cities", cities);
 }
 /// <summary>
 /// Create a new Cities object.
 /// </summary>
 /// <param name="iD1">Initial value of ID1.</param>
 /// <param name="iD2">Initial value of ID2.</param>
 public static Cities CreateCities(int iD1, global::System.Guid iD2)
 {
     Cities cities = new Cities();
     cities.ID1 = iD1;
     cities.ID2 = iD2;
     return cities;
 }