public CityName EditCityName(CityName cityName)
 {
     // Get original person object from database, no need to assig it to a variable
     GetCityName(cityName.CityId);
     _entities.CityNames.ApplyCurrentValues(cityName);
     _entities.SaveChanges();
     return cityName;
 }
Exemplo n.º 2
0
 public bool DeleteCityName(CityName cityName)
 {
     try
     {
         _cityNameRepository.DeleteCityName(cityName);
     }
     catch
     {
         return false;
     }
     return true;
 }
Exemplo n.º 3
0
        public bool EditCityName(CityName cityName)
        {
            // Validation logic
            if (!ValidateCityName(cityName))
                return false;

            // Database logic
            try
            {
                _cityNameRepository.EditCityName(cityName);
            }
            catch
            {
                return false;
            }
            return true;
        }
Exemplo n.º 4
0
 public bool ValidateCityName(CityName cityName)
 {
     if (cityName.CityName1.Trim().Length == 0)
         _validationDictionary.AddError("CityName", "City name is required.");
     if (cityName.State.Trim().Length == 0)
         _validationDictionary.AddError("State", "State is required.");
     return _validationDictionary.IsValid;
 }
 public void DeleteCityName(CityName cityName)
 {
     var originalPerson = GetCityName(cityName.CityId);
     _entities.CityNames.DeleteObject(cityName);
     _entities.SaveChanges();
 }
 public CityName CreateCityName(CityName cityName)
 {
     _entities.AddToCityNames(cityName);
     _entities.SaveChanges();
     return cityName;
 }
 /// <summary>
 /// Create a new CityName object.
 /// </summary>
 /// <param name="cityId">Initial value of the CityId property.</param>
 /// <param name="cityName1">Initial value of the CityName1 property.</param>
 /// <param name="state">Initial value of the State property.</param>
 public static CityName CreateCityName(global::System.Int32 cityId, global::System.String cityName1, global::System.String state)
 {
     CityName cityName = new CityName();
     cityName.CityId = cityId;
     cityName.CityName1 = cityName1;
     cityName.State = state;
     return cityName;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the CityNames EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCityNames(CityName cityName)
 {
     base.AddObject("CityNames", cityName);
 }