Beispiel #1
0
        public int GetFreeId()
        {
            //получим свободный id как максимальный плюс 1
            var cityDatastore = CityDatastore.GetInstance();
            int freeID        = cityDatastore.Cities.Keys.Max() + 1;

            return(freeID);
        }
Beispiel #2
0
        public CityGetModel UpdateCity(int id, CityGetModel City)
        {
            var cityDatastore = CityDatastore.GetInstance();

            CityGetModel updatedCity = cityDatastore.Cities[id];

            updatedCity.Name                    = City.Name;
            updatedCity.description             = City.description;
            updatedCity.NumberOfPintsOfInterest = City.NumberOfPintsOfInterest;

            return(updatedCity);
        }
Beispiel #3
0
        public CityGetModel AddCity(CityCreateModel newCity)
        {
            var          cityDatastore = CityDatastore.GetInstance();
            CityGetModel cityGetModel  = new CityGetModel();
            int          freeId        = GetFreeId();

            cityGetModel.Id                      = freeId;
            cityGetModel.Name                    = newCity.Name;
            cityGetModel.description             = newCity.description;
            cityGetModel.NumberOfPintsOfInterest = newCity.NumberOfPintsOfInterest;

            cityDatastore.Cities.Add(freeId, cityGetModel);
            return(cityGetModel);
        }
Beispiel #4
0
        public bool isPrezent(int idn)
        {
            CityDatastore cityDatastore = CityDatastore.GetInstance();

            return(cityDatastore.Cities.ContainsKey(idn));
        }
Beispiel #5
0
        public CityGetModel GetCityById(int idn)
        {
            CityDatastore cityDatastore = CityDatastore.GetInstance();

            return(cityDatastore.Cities[idn]);
        }
Beispiel #6
0
        public Dictionary <int, CityGetModel> GetAllCities()
        {
            CityDatastore cityDatastore = CityDatastore.GetInstance();

            return(cityDatastore.Cities);
        }
Beispiel #7
0
        public bool DeleteCity(int id)
        {
            var cityDatastore = CityDatastore.GetInstance();

            return(cityDatastore.Cities.Remove(id));
        }