Example #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (UserID.Length != 0)
            {
                hash ^= UserID.GetHashCode();
            }
            if (CityName.Length != 0)
            {
                hash ^= CityName.GetHashCode();
            }
            if (Password.Length != 0)
            {
                hash ^= Password.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #2
0
 public CityInformation(CityName aCityName, Color aColor, List <CityName> aNeighbors)
 {
     cityName    = aCityName;
     color       = aColor;
     neighbors   = aNeighbors;
     colorString = color.ToString();
 }
Example #3
0
        private void BtnFly_Click(object sender, EventArgs e)
        {
            ComboboxDialog dialog = new ComboboxDialog(cities);

            dialog.ShowDialog();
            if (dialog.SelectedCity != null)
            {
                if (CityName.Equals(dialog.SelectedCity.Name))
                {
                    MessageBox.Show("Увы, самолёт уже там.");
                }
                else if (plane.status != "В полёте")
                {
                    MessageBox.Show($"На перелет будет потрачено {game.RebasePlane(plane.ID, dialog.SelectedCity.ID)}$");
                    btnFly.Enabled = false;
                    CityName       = "В полёте";
                    plane.status   = "В полёте";
                }
                else
                {
                    MessageBox.Show("Самолёт уже в полёте.");
                }
            }
            else
            {
                if (dialog.PressCancel)
                {
                    return;
                }
                MessageBox.Show("Увы, туда самолёт послать нельзя.");
            }
        }
Example #4
0
 public Route(int id, CityName city1, CityName city2, int points)
 {
     Id     = id;
     City1  = city1;
     City2  = city2;
     Points = points;
 }
Example #5
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("CityNames/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyCityName = new CityName();

            if (await TryUpdateModelAsync <CityName>(
                    emptyCityName,
                    "cityname",                     // Prefix for form value
                    c => c.Name,
                    c => c.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.CityName.Add(emptyCityName);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
 public IEnumerable <CityDTO> EnumerateCitiesImpl(string cultureName)
 {
     using (DatabaseModel dbContext = new DatabaseModel())
     {
         foreach (City city in dbContext.Cities.ToArray())
         {
             CityName cityName = city.CityNames.FirstOrDefault(n => n.CultureName == cultureName);
             if (cityName == null)
             {
                 continue;
             }
             yield return(new CityDTO
             {
                 Id = city.Id,
                 CityName = cityName.Name,
                 InitialLatitude = city.InitialLatitude,
                 InitialLongitude = city.InitialLongitude,
                 InitialZoom = city.InitialZoom,
                 PhoneConstraintPattern = city.PhoneConstraintPattern,
                 PhoneCorrectionPattern = city.PhoneCorrectionPattern,
                 PhoneConstraintDescription = cityName.PhoneConstraintDescription
             });
         }
     }
 }
Example #7
0
        public void RandomNameIsReturned()
        {
            var sut   = new CityName();
            var value = sut.GetValue();

            Assert.IsFalse(string.IsNullOrEmpty(value));
        }
        public void RandomNameIsReturned()
        {
            var sut = new CityName();
            var value = sut.GetValue();

            Assert.IsFalse(string.IsNullOrEmpty(value));
        }
    public void addCityCard(CityName c)
    {
        cityCardNum++;
        GameObject g = Instantiate(PlayerCardPrefab, new Vector3(0, 0, 0), Quaternion.identity);
        Text       t = g.transform.GetChild(0).gameObject.GetComponent <Text>();

        g.GetComponent <Image> ().color = mapInstance.getCityColor(c);
        t.text = c.ToString();

        /*
         * if (cityCardNum != 1)
         * {
         *
         * foreach (Transform child in transform.GetChild(1))
         * {
         * child.position = child.position - new Vector3(maxSpace / 2, 0, 0);
         * }
         * }
         */
        g.transform.parent   = this.gameObject.transform;
        g.transform.position = playerCardStart.transform.position + new Vector3(0, 100, 0);
        //g.GetComponent<playerCardUI> ().setDestination (playerCardStart.transform.position);
        g.GetComponent <playerCardUI> ().setDestination(playerCardStart.transform.position + new Vector3(maxSpace * (cityCardNum - 1), 0, 0));
        //g.transform.position = playerCardStart.transform.position;
        //playerCardStart.transform.position += new Vector3(maxSpace/2, 0, 0);



        g.transform.parent = transform.GetChild(1);
    }
    //delete city card from gui
    public void deleteCityCard(CityName c)
    {
        bool find = false;

        foreach (Transform child in transform.GetChild(1))
        {
            if (!find && child.GetChild(0).GetComponent <Text>().text.Equals(c.ToString()))
            {
                find = true;
                Destroy(child.gameObject);
            }

            /*else if (!find)
             * {
             *  child.position = child.position + new Vector3(maxSpace / 2, 0, 0);
             * }*/
            else if (find)
            {
                //child.position = child.position -new Vector3(maxSpace / 2, 0, 0);
                child.GetComponent <playerCardUI> ().setDestination(child.transform.position - new Vector3(maxSpace, 0, 0));
            }
        }
        //playerCardStart.transform.position -= new Vector3(maxSpace / 2, 0, 0);

        cityCardNum--;
    }
Example #11
0
        /// <summary>
        /// This is testing if given string is somewhere in the location's texts
        /// </summary>
        /// <param name="subString"></param>
        /// <returns>returns code of field, where substring was found.
        /// Zero (0) means substring was not found.
        /// 1 : string was found at the start of Name or AlternativeName
        /// 2 : string was found within Name
        /// 3 : string was found within Alternative Name</returns>
        public int ContainsSubstring(string subString)
        {
            if (CityName.StartsWith(subString, StringComparison.CurrentCultureIgnoreCase) ||
                (ASCIIName != null && ASCIIName.StartsWith(subString, StringComparison.CurrentCultureIgnoreCase)))
            {
                return(1);
            }
            if (CityName.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase) >= 0 ||
                (ASCIIName != null && ASCIIName.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase) >= 0))
            {
                return(2);
            }
            int index = AlternativeNames.IndexOf(subString, 0, StringComparison.CurrentCultureIgnoreCase);

            if (index > 0)
            {
                return((AlternativeNames[index - 1] == ',') ? 1 : 3);
            }
            else if (index == 0)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
        public void AddCity_When_city_Then_SaveChanges_of_UnitOfWork_called()
        {
            // Arrange
            var city1 = new CityName {
                Id = 1, Name = "City1"
            };
            var city2 = new CityName {
                Id = 2, Name = "City2"
            };

            var cityRepository = A.Fake <IRepository <CityName> >();

            A.CallTo(() => cityRepository.Query()).Returns(new[] { city1 }.AsQueryable());

            var unitOfWork = A.Fake <IUnitOfWork>();

            A.CallTo(() => unitOfWork.Repository <CityName>()).Returns(cityRepository);

            var unitOfWorkFactory = A.Fake <IUnitOfWorkFactory>();

            A.CallTo(() => unitOfWorkFactory.Create()).Returns(unitOfWork);

            var service = new WeatherService(unitOfWorkFactory);

            // Act
            service.AddCity(city2);

            // Assert
            A.CallTo(() => unitOfWork.SaveChanges()).MustHaveHappened(Repeated.Exactly.Once);
        }
    public void addCityCard(CityName c)
    {
        content.GetChild(cityCardNum + eventCardNum).gameObject.SetActive(true);
        cityCardNum++;

        if (eventCardNum != 0)
        {
            for (int i = eventCardNum; i > 0; i--)
            {
                content.GetChild(cityCardNum + i - 1).GetChild(0).GetComponent <Text>().text  = content.GetChild(cityCardNum + i - 2).GetChild(0).GetComponent <Text>().text;
                content.GetChild(cityCardNum + i - 1).GetChild(0).GetComponent <Text>().color = content.GetChild(cityCardNum + i - 2).GetChild(0).GetComponent <Text>().color;
                content.GetChild(cityCardNum + i - 1).GetComponent <Image>().color            = content.GetChild(cityCardNum + i - 2).GetComponent <Image>().color;
            }
        }
        //adjust text color
        content.GetChild(cityCardNum - 1).GetChild(0).GetComponent <Text>().text = c.ToString();
        content.GetChild(cityCardNum - 1).GetComponent <Image>().color           = map.getCityColor(c);

        if (content.GetChild(cityCardNum - 1).GetComponent <Image>().color == Color.black)
        {
            content.GetChild(cityCardNum - 1).GetChild(0).GetComponent <Text>().color = Color.white;
        }
        else
        {
            content.GetChild(cityCardNum - 1).GetChild(0).GetComponent <Text>().color = Color.black;
        }

        setBar();
    }
 public XElement Serialize(string name)
 {
     return(new XElement(UblNames.Cac + name,
                         ID.Serialize(nameof(ID)),
                         AddressTypeCode.Serialize(nameof(AddressTypeCode)),
                         AddressFormatCode.Serialize(nameof(AddressFormatCode)),
                         Postbox.Serialize(nameof(Postbox)),
                         Floor.Serialize(nameof(Floor)),
                         Room.Serialize(nameof(Room)),
                         StreetName.Serialize(nameof(StreetName)),
                         AdditionalStreetName.Serialize(nameof(AdditionalStreetName)),
                         BlockName.Serialize(nameof(BlockName)),
                         BuildingName.Serialize(nameof(BuildingName)),
                         BuildingNumber.Serialize(nameof(BuildingNumber)),
                         InhouseMail.Serialize(nameof(InhouseMail)),
                         Department.Serialize(nameof(Department)),
                         MarkAttention.Serialize(nameof(MarkAttention)),
                         MarkCare.Serialize(nameof(MarkCare)),
                         PlotIdentification.Serialize(nameof(PlotIdentification)),
                         CitySubdivisionName.Serialize(nameof(CitySubdivisionName)),
                         CityName.Serialize(nameof(CityName)),
                         PostalZone.Serialize(nameof(PostalZone)),
                         CountrySubentity.Serialize(nameof(CountrySubentity)),
                         CountrySubentityCode.Serialize(nameof(CountrySubentityCode)),
                         Region.Serialize(nameof(Region)),
                         District.Serialize(nameof(District)),
                         TimezoneOffset.Serialize(nameof(TimezoneOffset)),
                         AddressLines?.Select(line => new XElement(UblNames.Cac + "AddressLine", line.Serialize("Line"))),
                         Country?.Serialize(),
                         LocationCoordinates?.Select(lc => lc.Serialize())
                         ));
 }
Example #15
0
        public IHttpActionResult PutCityName(int id, CityName cityName)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #16
0
 public void AddCity(CityName city)
 {
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         unitOfWork.Repository <CityName>().Add(city);
         unitOfWork.SaveChanges();
     }
 }
Example #17
0
 public async Task AddCityAsync(CityName city)
 {
     using (var unitOfWork = _unitOfWorkFactory.Create())
     {
         unitOfWork.Repository <CityName>().Add(city);
         await unitOfWork.SaveChangesAsync();
     }
 }
Example #18
0
 public CityConnection(int id, CityName city1, CityName city2, TrainColor trainColor, int length)
 {
     Id         = id;
     City1      = city1;
     City2      = city2;
     TrainColor = trainColor;
     Length     = length;
 }
Example #19
0
 public void Rename(CityName newName)
 {
     if (_state.Status == CityStatus.InActive)
     {
         throw new InvalidOperationException("CityAggregate is inactive");
     }
     RaiseEvent(new CityRenamed(Id, newName, _state.Name));
 }
Example #20
0
        public IQueryable <CityName> GetCityNamesById(int id)
        {
            CityName cityName = db.CityNames.Find(id);

            return(db.CityNames);
            //List<CityName> cityName = db.CityNames.Where( data=>data.C_id = id).Select(data =>data.CityName1).Distinct().ToList();
            //return db.CityNames;
        }
Example #21
0
        public override int GetHashCode()
        {
            int hash = 17;

            hash = hash * 23 + (CityName == null ? 0 : CityName.GetHashCode());
            hash = hash * 23 + IsCityFrom.GetHashCode();
            return(hash);
        }
    private void InsertData(DataTable dt)
    {
        int UpdateCount = 0, InsertCount = 0;

        try
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                #region Value Initialization

                CountryName = dt.Rows[i][CountryNameColumn].ToString().Trim();
                StateName   = dt.Rows[i][StateNameColumn].ToString().Trim();
                CityName    = dt.Rows[i][CityNameColumn].ToString().Trim();

                #endregion

                int CountryId = new Country()
                {
                    eStatus = (int)eStatus.Active, CountryName = CountryName.ToLower()
                }.SelectList <Country>()[0].CountryId.Value;

                int StateId = 0;
                if (!StateName.zIsNullOrEmpty())
                {
                    StateId = new State()
                    {
                        CountryId = CountryId, StateName = StateName, eStatus = (int)eStatus.Active
                    }
                }
                .SelectList <State>()[0].StateId.Value;

                DataTable dtCity = new Query()
                {
                    CountryId  = CountryId,
                    StateId    = StateId,
                    CityName   = CityName.zFirstCharToUpper(),
                    eStatusNot = (int)eStatus.Delete
                }.Select(eSP.qry_City);

                var objCity = new City()
                {
                    CityId   = dtCity.Rows.Count > 0 ? dtCity.Rows[0][CS.CityId].zToInt() : (int?)null,
                    StateId  = StateId,
                    CityName = CityName,
                };

                if (objCity.CityId.HasValue)
                {
                    objCity.Update();
                    UpdateCount++;
                }
                else
                {
                    objCity.eStatus = (int)eStatus.Active;
                    objCity.Insert();
                    InsertCount++;
                }
            }
Example #23
0
        public bool Equals(ClockInfo other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(CityName.Equals(other.CityName) && TimeZoneId.Equals(other.TimeZoneId));
        }
Example #24
0
 public override int GetHashCode()
 {
     return(IataCode.GetHashCode()
            ^ Type.GetHashCode()
            ^ Name.GetHashCode()
            ^ DetailedName.GetHashCode()
            ^ CityName.GetHashCode()
            ^ CountryName.GetHashCode()
            ^ Id?.GetHashCode() ?? 0);
 }
Example #25
0
        public async Task DisplayWeatherAsync()
        {
            WeatherRender = Render.LoadingComponent();

            if (string.IsNullOrWhiteSpace(CityName))
            {
                WeatherRender = Render.ErrorComponent("Empty search. Please type smth");
                return;
            }

            var cityNamePlus = CityName.Trim().Replace(" ", "+");
            //OpenWeatherUri contains API key. It's better to use user secrets for that
            //in development environment but there's a client-side API call.
            var openWeatherUri = new Uri(
                "https://api.openweathermap.org/data/2.5/weather?q=" + cityNamePlus +
                "&APPID=d5bb735f9e1ce1a846ab736fc9d95dc6");

            var requestMessage = new HttpRequestMessage()
            {
                Method     = new HttpMethod("GET"),
                RequestUri = openWeatherUri
            };

            var httpClient = new HttpClient();

            var response = await httpClient.SendAsync(requestMessage);

            switch (response.StatusCode)
            {
            case HttpStatusCode.OK:
                var weatherJson = JObject.Parse(await response.Content.ReadAsStringAsync());

                var weather = new Weather
                {
                    Description = char.ToUpper(((string)weatherJson["weather"][0]["description"])[0]) +
                                  ((string)weatherJson["weather"][0]["description"]).Substring(1),
                    Temperature = (int)Math.Round((decimal)weatherJson["main"]["temp"] - 273.15m),
                    Pressure    = (decimal)weatherJson["main"]["pressure"],
                    Humidity    = (decimal)weatherJson["main"]["humidity"],
                    WindSpeed   = (decimal)weatherJson["wind"]["speed"],
                    IconUrl     = "http://openweathermap.org/img/w/" +
                                  (string)weatherJson["weather"][0]["icon"] + ".png"
                };
                WeatherRender = Render.WeatherComponent(weather);
                break;

            case HttpStatusCode.NotFound:
                WeatherRender = Render.ErrorComponent("City not found");
                break;

            default:
                WeatherRender = Render.ErrorComponent();
                break;
            }
        }
Example #26
0
 public override string ToString()
 {
     if (CityName.Equals("remote", StringComparison.InvariantCultureIgnoreCase))
     {
         return("Remote");
     }
     else
     {
         return($"{CityName}, {Province}");
     }
 }
Example #27
0
 private void OnFocusOutEvent(object o, FocusOutEventArgs args)
 {
     if (AcceptUnknownCities &&
         (!Text.ToLower().Contains(CityName.ToLower()) || string.IsNullOrWhiteSpace(CityName))
         )
     {
         CityName = Text;
         UpdateFromFias();
         FireCityChange();
     }
 }
Example #28
0
        public IHttpActionResult GetCityName(int id)
        {
            CityName cityName = db.CityNames.Find(id);

            if (cityName == null)
            {
                return(NotFound());
            }

            return(Ok(cityName));
        }
Example #29
0
        public void Update()
        {
            string        strsql        = "update City set " + "CityName= '" + CityName.Replace("'", "''") + "', " + "StateId= " + StateId + ", " + "CountryId= " + CountryId + ", " + "Status= '" + Status.Replace("'", "''") + "' " + " where ID =" + Id;
            SqlConnection ObjConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyJobPortal"].ConnectionString);

            ObjConnection.Open();
            SqlCommand ObjCommand = new SqlCommand(strsql, ObjConnection);

            ObjCommand.ExecuteNonQuery();
            ObjConnection.Dispose();
            ObjCommand.Dispose();
        }
Example #30
0
        private void BtnClick_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(CityName.Text))
            {
                CityBox.Items.Add(CityName.Text);
                StateList.Items.Add(StateName.Text);
            }

            MessageBox.Show("City Added");
            CityName.Clear();
            StateName.Clear();
        }
Example #31
0
    public City(CityName name)
    {
        cityName = name;
        color    = Maps.getInstance().getCityColor(name);
        numberOfCubes.Add(Color.black, 0);
        numberOfCubes.Add(Color.blue, 0);
        numberOfCubes.Add(Color.magenta, 0);
        numberOfCubes.Add(Color.yellow, 0);
        numberOfCubes.Add(Color.red, 0);

        //UI only
    }