private async Task <Session> AcceptRename(SessionViewModel sessionViewModel) { if (sessionViewModel.Name == sessionViewModel.Session.Name) { sessionViewModel.EditingSession = false; return(sessionViewModel.Session); } sessionViewModel.Session.Name = sessionViewModel.Name; await _sessionRepository.UpdateSessionAsync(sessionViewModel.Session).ConfigureAwait(false); sessionViewModel.EditingSession = false; return(sessionViewModel.Session); }
private async Task AddSessionAsync() { var maxSessionNumber = Sessions .Select(sessionVM => Constants.Sessions.NewSessionNameRegex.Match(sessionVM.Session.Name)) .Where(match => match.Success) .Select(match => int.Parse(match.Groups[1].Value)) .DefaultIfEmpty(0) .Max(); var nextAvailableNumber = maxSessionNumber + 1; var session = new Session(_event, $"{Constants.Sessions.NewSessionNameBase}{nextAvailableNumber}"); await _sessionRepository.AddSessionAsync(session).ConfigureAwait(true); var sessionVM = new SessionViewModel(session); Sessions.Add(sessionVM); }
private async Task DeleteSessionAsync(SessionViewModel sessionViewModel) { await _sessionRepository.DeleteSessionAsync(sessionViewModel.Session).ConfigureAwait(false); Sessions.Remove(sessionViewModel); }