Source

main / Source / Excel / Excel.AddIn / Excel.AddIn / ViewModels / RepositoryDetailListViewModel.cs

Full commit
Naethra D ba1cb57 







































































using System.Collections.ObjectModel;

namespace DataUp.Excel.Addin
{
    public class RepositoryDetailListViewModel : ViewModelBase
    {
        private ObservableCollection<RepositoryDetailsViewModel> repositoryList;

        private RepositoryDetailsViewModel repositoryDetailsViewModel;

        public RepositoryDetailsViewModel RepositoryDetailsViewModel
        {
            get
            {
                return repositoryDetailsViewModel;
            }
            set
            {
                repositoryDetailsViewModel = value;
                OnNotifyPropertyChanged("RepositoryDetailsViewModel");
                if (this.RepositoryDetailsViewModel != null)
                {
                    this.RepositoryDetailsViewModel.LoadFromCache();
                }
            }
        }

        public ObservableCollection<RepositoryDetailsViewModel> RepositoryList
        {
            get
            {
                return repositoryList;
            }
            set
            {
                repositoryList = value;
                OnNotifyPropertyChanged("RepositoryList");
            }
        }

        public RepositoryDetailListViewModel()
        {
            this.RepositoryDetailsViewModel = new RepositoryDetailsViewModel();
            this.RepositoryList = new ObservableCollection<RepositoryDetailsViewModel>();
        }

        public void LoadValues()
        {
            this.RepositoryList.Clear();

            foreach (var repository in Controller.Instance.GetRepositories())
            {
                this.RepositoryList.Add(new RepositoryDetailsViewModel()
                {
                    IsPasswordRequired = repository.IsPasswordRequired,
                    RepositoryName = repository.RepositoryName,
                    RepositoryType = repository.RepositoryType
                });
            }

            if (this.RepositoryDetailsViewModel != null)
            {
                this.RepositoryDetailsViewModel.Clear();
                this.RepositoryDetailsViewModel.LoadFromCache();
            }
            else
            {
                this.RepositoryDetailsViewModel = new RepositoryDetailsViewModel();
                this.RepositoryDetailsViewModel.LoadFromCache();
            }
        }
    }
}