Пример #1
0
        public void SaveSnippet()
        {
            try
            {
                BLL.ISnippetRepository snippetRepository    = SnippetRepositoryFactory.GetRepository(Settings.Default.repoType);
                BLL.SnippetCollection  bllSnippetCollection = new BLL.SnippetCollection();

                foreach (Snippet s in _dirtySnippetsCollection)
                {
                    BLL.Snippet snippet = new BLL.Snippet()
                    {
                        Code = s.Code, Title = s.Title, Language = s.Language
                    };
                    bllSnippetCollection.Add(snippet);
                }

                snippetRepository.UpdateAllSnippets(bllSnippetCollection);

                _snippetsOriginal = _dirtySnippetsCollection.ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something went wrong");
            }
        }
Пример #2
0
 public SnippetCollection(BLL.SnippetCollection snippetCollection)
 {
     foreach (BLL.Snippet snippet in snippetCollection)
     {
         this.Add(new Snippet(snippet));
     }
 }
Пример #3
0
        public CodeStash3ViewModel()
        {
            try
            {
                BLL.ISnippetRepository snippetRepository;
                BLL.SnippetCollection  bllSnippetCollection;


                snippetRepository    = SnippetRepositoryFactory.GetRepository(Settings.Default.repoType);
                bllSnippetCollection = new BLL.SnippetCollection(snippetRepository);

                _snippetsOriginal        = new SnippetCollection(bllSnippetCollection).ToList();
                _dirtySnippetsCollection = new ObservableCollection <Snippet>(_snippetsOriginal);
                _languages = new LanguageCollection(new BLL.LanguageCollection(bllSnippetCollection).GenerateLanguageList());
            }
            catch (Exception e)
            {
                MessageBox.Show("An error has occured");
            }
        }