private void AddPhone() { if (AddAddressPhoneEmailInteractioNRequest != null) { var itemVm = _phoneVmFactory.GetViewModelInstance(new KeyValuePair <string, object>("item", new Phone())); var confirmation = new ConditionalConfirmation { Title = "Enter phone details".Localize(), Content = itemVm }; AddAddressPhoneEmailInteractioNRequest.Raise(confirmation, (x) => { if (x.Confirmed) { var phoneToAdd = (x.Content as IPhoneNumberDialogViewModel) .InnerItem; ContactPhones.Add(phoneToAdd); AddPhoneCommand.RaiseCanExecuteChanged(); } }); } }
public void AddPhone() { var addPhoneCommand = new AddPhoneCommand(customer, phone); customerManager.SetCommand(addPhoneCommand); customerManager.ExecuteCommand(); }
public string ExecuteCommand(string commandName, string[] commandArguments) { ICommand command = null; if (commandName == "AddPhone" && commandArguments.Length >= 2) { command = new AddPhoneCommand(this.phonebookRepository, commandArguments); } else if (commandName == "ChangePhone" && commandArguments.Length == 2) { command = new ChangePhoneCommand(this.phonebookRepository, commandArguments); } else if (commandName == "List" && commandArguments.Length == 2) { command = new ListCommand(this.phonebookRepository, commandArguments); } else { return "Invalid command"; } string commandResult; try { commandResult = command.Execute(); } catch (Exception e) { commandResult = e.Message; } return commandResult; }
private void RemovePhone(Phone item) { if (ContactPhones != null) { ContactPhones.Remove(item); AddPhoneCommand.RaiseCanExecuteChanged(); } }
public IPhoneBookCommand CreateCommand(string commandName, int argumentsCount) { IPhoneBookCommand command; if (commandName.StartsWith("AddPhone") && (argumentsCount >= 2)) { command = new AddPhoneCommand(data, printer, sanitizer); } else if ((commandName == "ChangePhone") && (argumentsCount == 2)) { command = new ChangePhoneCommand(data, printer, sanitizer); } else if ((commandName == "List") && (argumentsCount == 2)) { command = new ListPhonesCommand(data, printer); } else { throw new ArgumentException("Invalid command"); } return command; }
public IPhoneBookCommand CreateCommand(string commandName, int argumentsCount) { IPhoneBookCommand command; if (commandName.StartsWith("AddPhone") && (argumentsCount >= 2)) { command = new AddPhoneCommand(data, printer, sanitizer); } else if ((commandName == "ChangePhone") && (argumentsCount == 2)) { command = new ChangePhoneCommand(data, printer, sanitizer); } else if ((commandName == "List") && (argumentsCount == 2)) { command = new ListPhonesCommand(data, printer); } else { throw new ArgumentException("Invalid command"); } return(command); }
public async Task <IActionResult> Phone([FromBody] AddPhoneCommand command) { await _commandBus.ExecuteAsync(command); return(Created("Phone was created", null)); }