示例#1
0
        // Returns the current city from database
        /// <summary>
        /// Returns the current city from database.
        /// </summary>
        /// <returns></returns>
        private string ReturnCity()
        {
            DataBaseLocalizationDbContext db = new DataBaseLocalizationDbContext();
            var r = from d in db.DataBaseLocalizations1
                    where d.Id == 1
                    select d;
            DataBaseLocalization1 obj = r.SingleOrDefault();

            return(obj.Localization.ToString());
        }
        // Loads the current city from database
        /// <summary>
        /// Loads the current city  from database
        /// </summary>
        private void CityInitialization()
        {
            DataBaseLocalizationDbContext db = new DataBaseLocalizationDbContext();
            var r = from d in db.DataBaseLocalizations1
                    select d;
            DataBaseLocalization1 obj = r.SingleOrDefault();

            if (obj == null)
            {
                DataBaseLocalization1 doctroObject = new DataBaseLocalization1()
                {
                    Localization = "Wrocław",
                };
                db.DataBaseLocalizations1.Add(doctroObject);
                db.SaveChanges();
            }
        }