public void Handle(DeletePersonCommand command)
        {
            var person = _domainRepository.GetById(command.Id);

            person.Delete();
            _domainRepository.Save(person, -1);
        }
Beispiel #2
0
        public async Task <IActionResult> Delete(int personId)
        {
            var command  = new DeletePersonCommand(personId);
            var response = await _mediator.Send(command).ConfigureAwait(false);

            return(Ok(response));
        }
Beispiel #3
0
        public async Task <IActionResult> DeletePerson(Guid id)
        {
            var command = new DeletePersonCommand
            {
                PersonId = id
            };

            return(Ok(await _mediator.Send(command)));
        }
        public async Task <IActionResult> Delete([FromBody] Guid id)
        {
            var user = await _userManagerWrapper.FindByNameAsync(User.Identity.Name);

            var deletePersonCommand = new DeletePersonCommand {
                Id = id, UserId = user.Id
            };
            await _endpointInstance.Send("LifeManager.People", deletePersonCommand).ConfigureAwait(false);

            return(Ok());
        }
        public async Task <IActionResult> DeleteAsync([FromBody] DeletePersonCommand command)
        {
            var result = await _commandExecutor.ExecuteAsync(command);

            if (!result.Success)
            {
                return(BadRequest(new { success = false }));
            }

            return(Ok(new { success = true }));
        }
        public async Task TestDeleteNonExistingPerson()
        {
            // Arrange
            var command = new DeletePersonCommand()
            {
                Id = "1"
            };

            // Act & assert
            await Assert.ThrowsAsync <ValidationException>(
                async() => await DeletePersonHandler.Handle(command, CancellationToken.None));
        }
Beispiel #7
0
        public async Task Delete_Person()
        {
            using (var context = GetContextWithData())
            {
                var handler = new DeletePersonCommandHandler(context);
                var command = new DeletePersonCommand
                {
                    Id = (await context.Persons.Skip(1).Take(1).FirstOrDefaultAsync()).Id
                };

                await handler.Handle(command, CancellationToken.None);
                Assert.Null(await context.Persons.FindAsync(command.Id));
            }
        }
Beispiel #8
0
        public ActionResult <Person> Delete(int id)
        {
            var command = new DeletePersonCommand(id);

            command.Execute();
            if (!command.GetResult().Succeeded)
            {
                return(BadRequest("Could not delete a person"));
            }

            var result = command.GetResult() as DeletePersonResult;

            return(Ok(result.Person));
        }
Beispiel #9
0
        public void Handle(DeletePersonCommand message)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return;
            }

            personRepository.Remove(message.Id);

            if (Commit())
            {
                //Bus.RaiseEvent(new CustomerRemovedEvent(message.Id));
            }
        }
        public async Task TestDeleteExistingPerson()
        {
            // Arrange
            SetupGetPersonById(new Person());
            var command = new DeletePersonCommand()
            {
                Id = "1"
            };

            // Act
            var result = await DeletePersonHandler.Handle(command, CancellationToken.None);

            // Assert
            Assert.IsType <MediatR.Unit>(result);
        }
        public void DeletePerson()
        {
            DeletePersonCommand dpc = new DeletePersonCommand(1);

            dpc.Execute();
            DeletePersonResult dpr = dpc.GetResult() as DeletePersonResult;

            Assert.IsTrue(dpr.Succeeded);
            Assert.AreEqual(1, dpr.Person.Id);
            Assert.AreEqual("Boris", dpr.Person.Name);
            Assert.AreEqual("Britian", dpr.Person.Nationality);

            GetPersonQuery gpq = new GetPersonQuery("Boris");

            gpq.Execute();
            GetPersonResult gpr = gpq.GetResult() as GetPersonResult;

            Assert.IsTrue(gpr.Succeeded);
            Assert.AreEqual(0, gpr.Persons.Count);
        }
Beispiel #12
0
        public IActionResult Delete_person(DeletePersonCommand delete_person_command)
        {
            _logger.LogInformation($"delete person command, id: { delete_person_command.Id }");

            using (var msgpump = new MessagePump(_es))
            {
                var context_manager   = new DeletePersonCommandContextManager(_es);
                var message_processor = new DeletePersonCommandProcessor();
                msgpump.Register <DeletePersonCommand>(context_manager, message_processor);

                var result = msgpump.Handle(delete_person_command) as CommandStatus;
                if (result is Success)
                {
                    return(Ok());
                }
                else
                {
                    return(BadRequest());
                }
            }
        }
Beispiel #13
0
 public void Delete(DeletePersonCommand command)
 {
     Request(PersonListApiActions.Delete, Method.DELETE, command);
 }
 private void UpdateCommandCanExecuteOnSelectedPersonChanged()
 {
     DeletePersonCommand.RaiseCanExecuteChanged();
     ShowEditPersonCommand.RaiseCanExecuteChanged();
     CreateShooterCommand.RaiseCanExecuteChanged();
 }
Beispiel #15
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            if (IsInDesignMode)
            {
                DataModel.PersonList.Add(new Person {
                    Age = 39, Name = "Andy"
                });
                DataModel.PersonList.Add(new Person {
                    Age = 40, Name = "Herbie"
                });
                DataModel.PersonList.Add(new Person {
                    Age = 36, Name = "Ebe"
                });
            }
            else
            {
                DataModel.PersonList.Add(new Person {
                    Age = 39, Name = "Andy"
                });
                DataModel.PersonList.Add(new Person {
                    Age = 40, Name = "Herbie"
                });
                DataModel.PersonList.Add(new Person {
                    Age = 36, Name = "Ebe"
                });
                DataModel.PersonList.Add(new Person {
                    Age = 51, Name = "Wolfgang"
                });
                DataModel.PersonList.Add(new Person {
                    Age = 48, Name = "Arno"
                });
            }

            InsertCommand = new RelayCommand(() =>
            {
                var cmd = new CreatePersonCommand()
                {
                    DataModel = DataModel, Name = name, Age = age
                };
                ExecuteCommand(cmd);
                Name = "";
                Age  = 20;
            });

            UndoCommand = new RelayCommand(() =>
            {
                undoRedoStack.Undo();
            });

            RedoCommand = new RelayCommand(() =>
            {
                undoRedoStack.Redo();
            });

            DeleteCommand = new RelayCommand(() =>
            {
                if (SelectedPerson != null)
                {
                    var cmd = new DeletePersonCommand()
                    {
                        DataModel = DataModel, PersonToDelete = SelectedPerson
                    };
                    ExecuteCommand(cmd);
                }
            });
        }
 // Run 'CanExecute' for all buttons
 private void RunAllCanExecute()
 {
     NewPersonCommand.RaiseCanExecuteChanged();
     UpdatePersonCommand.RaiseCanExecuteChanged();
     DeletePersonCommand.RaiseCanExecuteChanged();
 }
 protected virtual void OnSelectedIndexChanged()
 {
     OnPropertyChanged(new PropertyChangedEventArgs("Selected"));
     OnPropertyChanged(new PropertyChangedEventArgs("SelectedIndex"));
     DeletePersonCommand.RaiseCanExecuteChanged();
 }
Beispiel #18
0
        public async Task <IActionResult> Delete([FromQuery] DeletePersonCommand command)
        {
            var result = await _commandExecutor.ExecuteAsync(command);

            return(CommandResult(result, ResultStatusCode.Created));
        }
Beispiel #19
0
 protected override IEnumerable <Person> Handle(DeletePersonCommand request)
 {
     return(_db.DeletPersonById(request.Id));
 }
Beispiel #20
0
        public void Delete(int id)
        {
            var deleteCommand = new DeletePersonCommand(id);

            bus.SendCommand(deleteCommand);
        }
 public async Task <Unit> Delete([FromRoute] DeletePersonCommand command)
 {
     return(await Mediator.Send(command));
 }
Beispiel #22
0
 public async Task <ActionResult <int> > Delete(DeletePersonCommand deletePersonCommand)
 {
     return(await Mediator.Send(deletePersonCommand));
 }
 public async Task Handle(DeletePersonCommand message, IMessageHandlerContext context)
 {
     await _peopleService.DeletePerson(message.Id, message.UserId);
 }