public List <Call> DeleteCall(Call call) { CallHistory.Remove(call); return(CallHistory); }
public void DeleteCall(Call currentCall) { CallHistory.Remove(currentCall); }
public TelephonePageViewModel(PanaceaServices core, ObservableCollection <LiveTileFrame> tiles) { _core = core; _tiles = tiles; BuyServiceCommand = new RelayCommand(args => { if (_core.TryGetBilling(out IBillingManager bill)) { bill.NavigateToBuyServiceWizard(); } }); SignInCommand = new RelayCommand(args => { if (_core.TryGetUserAccountManager(out IUserAccountManager user)) { user.LoginAsync(); } }); DialPadKeyPressCommand = new RelayCommand(args => { var character = args.ToString(); if (int.TryParse(character, out int number)) { Number += number.ToString(); if (Number.StartsWith("00")) { Number = "+" + Number.Substring(2, Number.Length - 2); } } else if (character == "*" || character == "#") { Number += character.ToString(); } }); DialPadBackspaceCommand = new RelayCommand(args => { if (Number?.Length > 0) { Number = Number.Substring(0, Number.Length - 1); } }, args => Number?.Length > 0); DialPadAudioCallCommand = new RelayCommand(async args => { await Call(Number); }, args => Number?.Length > 2); DialPadVideoCallCommand = new RelayCommand(args => { }, args => Number?.Length > 2); HangUpCommand = new AsyncCommand(async args => { //Host.StopRinging(); if (_core.TryGetUiManager(out IUiManager ui)) { if (_userPhone?.IsIncoming == true && _userPhone?.IsInCall == false) { await _userPhone.Reject(); } if (_terminalPhone?.IsIncoming == true && _terminalPhone.IsInCall == false) { await _terminalPhone.Reject(); } if (_userPhone?.IsInCall == true || _userPhone?.IsBusy == true) { await _userPhone.HangUp(); } if (_terminalPhone?.IsInCall == true || _terminalPhone?.IsBusy == true) { await _terminalPhone.HangUp(); } } }); SpeedDialCallCommand = new RelayCommand(async args => { await Call(args.ToString()); }); CallInProgressKeyPressCommand = new RelayCommand(async args => { await _currentPhone.StartDtmf(args.ToString()); await Task.Delay(600); await _currentPhone.StopDtmf(args.ToString()); }); CallInProgressAnswerCommand = new AsyncCommand(async args => { await _currentPhone?.Answer(); }, args => { return(_currentPhone?.IsIncoming == true && _currentPhone?.IsInCall == false); }); CallInProgressVideoAnswerCommand = new AsyncCommand(async args => { }, args => { return(_currentPhone?.IsIncoming == true); }); CallInProgressMuteCommand = new RelayCommand(args => { Muted = true; _currentPhone.Mute(); }, args => !Muted); CallInProgressUnmuteCommand = new RelayCommand(args => { Muted = false; _currentPhone.Unmute(); }, args => Muted); RemoveCallHistoryItemCommand = new AsyncCommand(async args => { var item = args as CallLogItem; if (item == null) { return; } try { await _core.HttpClient.GetObjectAsync <object>("telephone/removecall/" + item.Id + "/"); CallHistory.Remove(item); } catch { if (_core.TryGetUiManager(out IUiManager ui)) { ui.Toast(_translator.Translate("Action failed. Please try again later.")); } } }); ManageContactsCommand = new RelayCommand(async args => { if (_core.TryGetUserAccountManager(out IUserAccountManager user)) { if (await user.RequestLoginAsync(_translator.Translate("You must create an account to use Telephone.")) && _core.TryGetUiManager(out IUiManager ui)) { if (ui.CurrentPage != this) { ui.Navigate(this); } var source = new TaskCompletionSource <bool>(); var vm = new ContactsPageViewModel(_userSpeedDials, source, _core); ui.Navigate(vm, false); var res = await source.Task; if (ui.CurrentPage != this) { ui.Navigate(this); } if (res) { IsBusy = true; try { await GetUserDialsAsync(); } finally { IsBusy = false; } } } } }); }