public CityViewModel(CITIES city) { this.CITYID = city.CITYID; this.CITYNAME = city.CITYNAME; GetRegions(); //DeleteCityCommand = new RelayCommand<CitiesViewModel>(p => DeleteCity(p), (p)=> { return p.CitiesList.Contains(this) && p.SelectedCity!=null; }); AddRegion = new RegionViewModel(); DeleteRegion = new RelayCommand(DeleteReg, () => { return(REGIONS.Contains(SelectedRegion)); }); }
public void SaveCity(CitiesViewModel p) { CITIES city = new CITIES(); city.CITYNAME = this.CITYNAME; this.CITYNAME = ""; DbContext.CITIES.Add(city); DbContext.SaveChanges(); p.CitiesList.Add(new CityViewModel(city)); }