Exemplo n.º 1
0
        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();
                    }
                });
            }
        }
Exemplo n.º 2
0
        public void AddPhone()
        {
            var addPhoneCommand = new AddPhoneCommand(customer, phone);

            customerManager.SetCommand(addPhoneCommand);
            customerManager.ExecuteCommand();
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 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;
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Phone([FromBody] AddPhoneCommand command)
        {
            await _commandBus.ExecuteAsync(command);

            return(Created("Phone was created", null));
        }