public ActionResult CreateRepository(DatabaseType dataSourceType = DatabaseType.Memory) { using (var stopWatch = new StopWatchCalculator()) { var database = repositoryFactory.GetDatabase(dataSourceType); database.Create(); return(View("Index", new ContactsViewModel(dataSourceType, true, new Contact[0], stopWatch.ElapsedTime))); } }
public ActionResult DropRepository() { using (var stopWatch = new StopWatchCalculator()) { var database = repositoryFactory.GetDatabase(GetDataSourceType()); database.Drop(); return(View("Index", new ContactsViewModel(GetDataSourceType(), false, new Contact[0], stopWatch.ElapsedTime))); } }
public ActionResult RemoveContact(Guid id) { using (var stopWatch = new StopWatchCalculator()) { var database = repositoryFactory.GetDatabase(GetDataSourceType()); using (var session = database.OpenSession()) { session.ContactRepository.Remove(id); session.Commit(); return(View("Index", new ContactsViewModel(GetDataSourceType(), true, session.ContactRepository.ToArray(), stopWatch.ElapsedTime))); } } }
public ActionResult Index() { var dataSourceType = GetDataSourceType(); var database = repositoryFactory.GetDatabase(dataSourceType); if (!database.Exist()) { return(View(new ContactsViewModel(dataSourceType, false, new Contact[0]))); } using (var stopWatch = new StopWatchCalculator()) { using (var session = database.OpenSession()) { var contacts = session.ContactRepository.ToArray(); return(View(new ContactsViewModel(dataSourceType, true, contacts, stopWatch.ElapsedTime))); } } }