private void ExportTable(RandomTableViewModel tableViewModel) { Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.Filter = "Table Archive|*.ccea|Word Document|*.docx"; saveFileDialog.Title = "Save Table"; saveFileDialog.FileName = tableViewModel.Name; if (saveFileDialog.ShowDialog() == true) { try { string ext = Path.GetExtension(saveFileDialog.FileName); if (ext == ".ccaa") { byte[] bytes = _dataManager.CreateTableArchive(tableViewModel.RandomTableModel); File.WriteAllBytes(saveFileDialog.FileName, bytes); } else if (ext == "*.docx") { //_documentService.CreateWordDoc(saveFileDialog.FileName, tableViewModel); } else { _dialogService.ShowConfirmationDialog("Unable To Export", "Invalid file extension.", "OK", null, null); } } catch (Exception) { _dialogService.ShowConfirmationDialog("Unable To Export", "An error occurred when attempting to export the table.", "OK", null, null); } } }
// GET: Tables public ActionResult Random() { var table = new Table() { Name = "Spitz Raphael" }; var personSubscribeds = new List <PersonSubscribed> { new PersonSubscribed { Name = "Client 1" }, new PersonSubscribed { Name = "Client 2" }, new PersonSubscribed { Name = "Client 3" } }; var viewModel = new RandomTableViewModel { Table = table, PersonSubscribeds = personSubscribeds }; return(View(viewModel)); }
private void SelectPrevious() { if (_tables.Any()) { ListItemViewModel <RandomTableModel> selected = _tables.FirstOrDefault(x => x.IsSelected); foreach (ListItemViewModel <RandomTableModel> table in _tables) { table.IsSelected = false; } if (selected == null) { _tables[_tables.Count - 1].IsSelected = true; _selectedTable = new RandomTableViewModel(_tables[_tables.Count - 1].Model); } else { int index = Math.Max(_tables.IndexOf(selected) - 1, 0); _tables[index].IsSelected = true; _selectedTable = new RandomTableViewModel(_tables[index].Model); } OnPropertyChanged(nameof(SelectedTable)); } }
private void Delete() { if (_selectedTable != null) { string message = String.Format("Are you sure you want to delete {0}?", _selectedTable.Name); bool?result = _dialogService.ShowConfirmationDialog("Delete Table", message, "Yes", "No", null); if (result == true) { _compendium.DeleteTable(_selectedTable.RandomTableModel.Id); ListItemViewModel <RandomTableModel> listItem = _tables.FirstOrDefault(x => x.Model.Id == _selectedTable.RandomTableModel.Id); if (listItem != null) { _tables.Remove(listItem); } _selectedTable = null; _compendium.SaveTables(); OnPropertyChanged(nameof(SelectedTagOption)); OnPropertyChanged(nameof(SelectedTable)); if (_tableEditViewModel != null) { CancelEditTable(); } } } }
private void EditTable(RandomTableViewModel tableModel) { if (tableModel != null) { _tableEditViewModel = new RandomTableEditViewModel(tableModel.RandomTableModel); _tableEditViewModel.PropertyChanged += _tableEditViewModel_PropertyChanged; OnPropertyChanged(nameof(EditingTable)); OnPropertyChanged(nameof(IsEditingTable)); } }
public ActionResult MyProposal() { var tables = _context.Table.Include(t => t.ApplicationUser).Include(t => t.Files).Include(t => t.Address).Include(t => t.Menu).ToList(); var viewModel = new RandomTableViewModel { Tables = tables, CurentUserId = User.Identity.GetUserId().ToString() }; return(View(viewModel)); }
// [Route("/Tables/Details/{id}")] public ActionResult Details(int id) { var table = _context.Table.Include(t => t.ApplicationUser). Include(t => t.Files).Include(t => t.Address).Include(t => t.Menu).SingleOrDefault(t => t.Id == id); var viewModel = new RandomTableViewModel { Table = table }; return(View(viewModel)); }
public ActionResult MyReservations() { var reservations = _context.Reservations.Include(R => R.Table).Include(R => R.Table.Menu).Include(R => R.Table.Address).ToList(); var viewModel = new RandomTableViewModel { Reservations = reservations, CurentUserId = User.Identity.GetUserId().ToString() }; return(View(viewModel)); }
public ActionResult TablesReservationListAvailibility() { var tables = _context.Table.Include(t => t.ApplicationUser).Include(t => t.Menu).Include(t => t.Address).ToList(); var viewModel = new RandomTableViewModel { Tables = tables, }; return(View(viewModel)); }
private void SelectTable(ListItemViewModel <RandomTableModel> tableItem) { bool selectTable = true; if (_tableEditViewModel != null) { if (_editHasUnsavedChanges) { string body = String.Format("{0} has unsaved changes.{1}What would you like to do?", _selectedTable.Name, Environment.NewLine + Environment.NewLine); string accept = "Save and Continue"; string reject = "Discard Changes"; string cancel = "Cancel Navigation"; bool? result = _dialogService.ShowConfirmationDialog("Unsaved Changes", body, accept, reject, cancel); if (result == true) { if (!SaveEditTable()) { selectTable = false; } } else if (result == false) { CancelEditTable(); } else { selectTable = false; } } else { CancelEditTable(); } } if (selectTable) { foreach (ListItemViewModel <RandomTableModel> item in _tables) { item.IsSelected = false; } tableItem.IsSelected = true; _selectedTable = new RandomTableViewModel(tableItem.Model); OnPropertyChanged(nameof(SelectedTable)); } }
private bool SaveEditTable() { bool saved = false; if (_tableEditViewModel.RandomTableModel != null) { _tableEditViewModel.RandomTableModel.Id = _selectedTable.RandomTableModel.Id; _compendium.UpdateTable(_tableEditViewModel.RandomTableModel); _selectedTable = new RandomTableViewModel(_tableEditViewModel.RandomTableModel); ListItemViewModel <RandomTableModel> oldListItem = _tables.FirstOrDefault(x => x.Model.Id == _tableEditViewModel.RandomTableModel.Id); if (oldListItem != null) { if (_tableSearchService.SearchInputApplies(_tableSearchInput, _tableEditViewModel.RandomTableModel)) { InitializeListItemDetails(oldListItem, _tableEditViewModel.RandomTableModel); } else { _tables.Remove(oldListItem); } } _tableEditViewModel = null; _editHasUnsavedChanges = false; SortTables(); _compendium.SaveTables(); OnPropertyChanged(nameof(SelectedTagOption)); OnPropertyChanged(nameof(SelectedTable)); OnPropertyChanged(nameof(EditingTable)); OnPropertyChanged(nameof(IsEditingTable)); OnPropertyChanged(nameof(HasUnsavedChanges)); saved = true; } return(saved); }
private void Copy() { if (_selectedTable != null) { bool copyTable = true; if (_tableEditViewModel != null) { if (_editHasUnsavedChanges) { string body = String.Format("{0} has unsaved changes.{1}What would you like to do?", _selectedTable.Name, Environment.NewLine + Environment.NewLine); string accept = "Save and Continue"; string reject = "Discard Changes"; string cancel = "Cancel Navigation"; bool? result = _dialogService.ShowConfirmationDialog("Unsaved Changes", body, accept, reject, cancel); if (result == true) { if (!SaveEditTable()) { copyTable = false; } } else if (result == false) { CancelEditTable(); } else { copyTable = false; } } else { CancelEditTable(); } } if (copyTable) { RandomTableModel tableModel = new RandomTableModel(_selectedTable.RandomTableModel); tableModel.Name += " (copy)"; tableModel.Id = Guid.NewGuid(); _compendium.AddTable(tableModel); if (_tableSearchService.SearchInputApplies(_tableSearchInput, tableModel)) { ListItemViewModel <RandomTableModel> listItem = new ListItemViewModel <RandomTableModel>(tableModel); InitializeListItemDetails(listItem, tableModel); _tables.Add(listItem); foreach (ListItemViewModel <RandomTableModel> item in _tables) { item.IsSelected = false; } listItem.IsSelected = true; } _selectedTable = new RandomTableViewModel(tableModel); SortTables(); _compendium.SaveTables(); OnPropertyChanged(nameof(SelectedTable)); } } }