Beispiel #1
0
        private void InitializePersons()
        {
            using (var session = _documentStoreFactory.CreateDocumentStore().OpenSession())
            {
                var persons = session.LoadAll <Person>();
                Persons = new ObservableCollection <PersonViewModel>(persons.OrderBy(t => t.Lastname).ThenBy(t => t.Firstname).Select(s => IocKernel.GetPersonViewModel(this, s)).ToList());
            }

            Notify("Persons");

            SelectedListPerson = Persons.FirstOrDefault();
        }
Beispiel #2
0
        private void LoadDocuments()
        {
            _documents = new RevertableObservableCollection <DocumentViewModel, Document>(this);

            if (!IsNew)
            {
                using (var session = _documentStoreFactory.CreateDocumentStore().OpenSession())
                {
                    var documents          = session.Query <Document>().Where(t => t.PersonId == _id).ToList();
                    var documentViewModels = documents.Select(s => IocKernel.GetDocumentViewModel(this, s)).ToList();

                    _documents = new RevertableObservableCollection <DocumentViewModel, Document>(documentViewModels, this);
                }
            }
        }
Beispiel #3
0
        private void SavePersons(IList <Person> persons)
        {
            using (var session = _documentStoreFactory.CreateDocumentStore().OpenSession())
            {
                foreach (var person in persons)
                {
                    session.Store(person);
                }

                session.SaveChanges();
            }
        }
Beispiel #4
0
        public int Export(string filename)
        {
            _logger.Info(LoggerMessage.GetFunctionUsageMessage("Export Addressbook"));

            List <Person> persons = new List <Person>();

            using (var session = _documentStoreFactory.CreateDocumentStore().OpenSession())
            {
                persons = session.LoadAll <Person>();
            }

            var excelPackage = new ExcelPackage();

            excelPackage.Workbook.Properties.SetCustomPropertyValue("Version", 1);
            var worksheet = excelPackage.Workbook.Worksheets.Add("Zugab");

            var addressbookWorksheet = new AddressbookWorksheet(worksheet);

            addressbookWorksheet.WritePersons(persons);

            excelPackage.SaveAs(new FileInfo(filename));

            return(persons.Count);
        }
 public TwitterDocumentStore(IDocumentStoreFactory documentStoreFactory)
 {
     _documentStore = documentStoreFactory.CreateDocumentStore();
 }