public ActionResult DeleteConfirmed(int sessionId) { Request.ThrowIfDifferentReferrer(); var session = _database.Sessions .FilterById(sessionId) .AsDbQuery() .Include(s => s.Project) .SingleOrDefault(); var currentUser = _userManager.FindById(User.Identity.GetUserId()); int projectId; if (session != null) { if (session.Project.Owner == currentUser || User.IsInRole(UserRoles.ADMIN)) { projectId = session.ProjectId; var command = new DeleteSessionCommand() { Session = session, }; _recordings.DeleteSessionData(session); _dispatcher.Dispatch(command); return(RedirectToAction(nameof(ProjectController.Details), ProjectController.ControllerName, new { projectId = projectId })); } } return(HttpNotFound()); }
public SessionViewModel(HomeViewModel viewModel) { HomeViewModel = viewModel; ListSessionIsVisible = true; TimeParamSessionSwitchState = false; LocParamSessionSwitchState = false; LocTrackingSessionSwitchState = true; CurrentSession = new Session(); SaveSessionCommand = new SaveSessionCommand(this); RefreshSessionCommand = new RefreshSessionCommand(this); DeleteSessionCommand = new DeleteSessionCommand(this); List <String> lst = new List <String>() { "sessions", "stat", }; this.RibbonOptions = lst; List <StackLayout> SessionOpt = new List <StackLayout> { new ListSessionBodyView(this), new StatSessionBodyView(this) }; this.SessionViewOptions = SessionOpt; this.OptionSelectionChangedCommand = new Command((obj) => { var selectedItemRibbonIndex = obj.ToString(); HomeViewModel.IsToolbarMenuOpened = false; ListSessionIsVisible = false; AddSessionIsVisible = false; StatSessionIsVisible = false; if (selectedItemRibbonIndex == "0") { ListSessionIsVisible = true; } else if (selectedItemRibbonIndex == "1") { StatSessionIsVisible = true; } else { AddSessionIsVisible = true; } }); }
/// <summary> /// Initializes a new instance of the <see cref="SessionManagerToolWindowControl"/> class. /// </summary> public SessionManagerToolWindowControl( SessionManagerToolWindowState state, ISessionManager sessionManager, SaveCurrentSessionCommand saveCurrentSessionCommand, RestoreSessionCommand restoreSessionCommand, OpenSessionCommand openSessionCommand, CloseSessionDocumentsCommand closeSessionDocumentsCommand, DeleteSessionCommand deleteSessionCommand, PackageAccessor packageAccessor) { State = state; SessionManager = sessionManager; _openSessionCommand = openSessionCommand; _package = packageAccessor.Package; RestoreSessionCommand = new RelayCommand( param => _package.JoinableTaskFactory.RunAsync(async() => await restoreSessionCommand.ExecuteAsync(State.SelectedSession))); OpenSessionCommand = new RelayCommand( param => _package.JoinableTaskFactory.RunAsync(async() => await openSessionCommand.ExecuteAsync(State.SelectedSession))); CloseSessionDocumentsCommand = new RelayCommand( param => _package.JoinableTaskFactory.RunAsync(async() => await closeSessionDocumentsCommand.ExecuteAsync(State.SelectedSession))); DeleteSessionCommand = new RelayCommand( param => _package.JoinableTaskFactory.RunAsync(async() => await deleteSessionCommand.ExecuteAsync(State.SelectedSession))); RenameSessionCommand = new RelayCommand( param => _package.JoinableTaskFactory.RunAsync(async() => await RenameSessionAsync())); UpdateSessionCommand = new RelayCommand( param => _package.JoinableTaskFactory.RunAsync(async() => { if (MessageBox.Show($"Documents saved in \"{State.SelectedSession.Name}\" will be replaced with " + $"the currently opened documents. Are you sure you want to continue?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } await saveCurrentSessionCommand.ExecuteAsync(State.SelectedSession); })); this.InitializeComponent(); }
public async Task <ActionResult <SessionResultResponse> > Delete(DeleteSessionCommand command) { var result = await Mediator.Send(command); return(Ok(result)); }