Beispiel #1
0
 internal City ConvertDalCityToObjCity(FavoritesCity dalCity)
 {
     return(new City()
     {
         Key = dalCity.CityKey,
         LocalizedName = dalCity.Name,
     });
 }
Beispiel #2
0
        private WeatherDetails ConvertDalCityToWeatherDetails(FavoritesCity city)
        {
            WeatherDetails wd = new WeatherDetails();

            wd.Temperature              = new Temperature();
            wd.Temperature.Metric       = new TempratureDetails();
            wd.Temperature.Metric.Value = (double)city.CelsiusTemprature;
            wd.WeatherText              = city.WeatherText;
            return(wd);
        }
Beispiel #3
0
        internal void AddToFavorites(City cityData)
        {
            using (var ctx = new MyFavoritesWeatherEntities())
            {
                if (!ctx.FavoritesCities.Where(x => x.CityKey == cityData.Key).Any())
                {
                    var item = new FavoritesCity()
                    {
                        CityKey = cityData.Key,
                        Name    = cityData.LocalizedName,
                        Status  = (int)Enums.FavoriteStatus.Active
                    };

                    ctx.FavoritesCities.Add(item);
                    ctx.SaveChanges();
                }
            };
        }