using System; using System.Collections.Generic; using System.Linq; using System.Text; using GeographicRepresentation.Interfaces; using GeographicRepresentation.Lib.Model; namespace GeographicRepresentation.Lib.ViewModel { public class ContinentsListViewModel : IContinentsListViewModel { #region Members List<IReadOnlyContinentViewModel> m_Continents; #endregion #region Methods #region Ctor public ContinentsListViewModel() { m_Continents = new List<IReadOnlyContinentViewModel>(); LoadContinentsFromRepository(); } #endregion #region IContinentsListViewModel Members public IList<IReadOnlyContinentViewModel> Continents { get { return m_Continents; } } public void LoadContinentsFromRepository() { m_Continents.Clear(); List<Continent> continents = DataManager.Instance.GetAllContinents(); for (int iter = 0; iter < continents.Count; iter++) { m_Continents.Add(new ReadOnlyContinentViewModel(continents[iter])); } } /// <summary> /// Request to remove an object /// </summary> /// <param name="readOnlyObject">The selected object to remove</param> public void RemoveGeographicObject(IReadOnlyViewModel readOnlyObject) { if (readOnlyObject != null) { if (readOnlyObject.GetType().GetInterfaces().Contains(typeof(IReadOnlyContinentViewModel))) { DataManager.Instance.RemoveContinent(((IReadOnlyContinentViewModel)readOnlyObject).Id); // Remove the continent from the continents list m_Continents.Remove((IReadOnlyContinentViewModel)readOnlyObject); } else if (readOnlyObject.GetType().GetInterfaces().Contains(typeof(IReadonlyCountryViewModel))) { DataManager.Instance.RemoveCountry(((IReadonlyCountryViewModel)readOnlyObject).Id); } else if (readOnlyObject.GetType().GetInterfaces().Contains(typeof(IReadOnlyCityViewModel))) { DataManager.Instance.RemoveCity(((IReadOnlyCityViewModel)readOnlyObject).Id); } } } #endregion #endregion } }
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
The Next Version of Android - Some of What's Coming