public async Task <Unit> Handle(PersonDeleteCommand request, CancellationToken cancellationToken)
        {
            await _personRepository.DeletePerson(request.Name, request.LastName);

            await _busPublisher.PublishEventAsync(new PersonCreateOrDeleteEvent { Name = request.Name, LastName = request.LastName });

            return(Unit.Value);
        }
Beispiel #2
0
        public async Task <Unit> Handle(PersonCreateCommand request, CancellationToken cancellationToken)
        {
            Person mainPerson = _mapper.Map <Person>(request.Person);
            Person cleaning   = _personRepository.GetByNameAndLastName(mainPerson.Name, mainPerson.LastName).Result.FirstOrDefault();

            if (cleaning == null)
            {
                await _personRepository.CreatePerson(mainPerson);

                if (request.Parents != null)
                {
                    CreatePersonAndRelationship(request.Parents, mainPerson, true);
                }
                if (request.Children != null)
                {
                    CreatePersonAndRelationship(request.Children, mainPerson, false);
                }
                await _busPublisher.PublishEventAsync(new PersonCreateOrDeleteEvent { Name = request.Person.Name, LastName = request.Person.LastName, Region = request.Person.Region });
            }
            return(Unit.Value);
        }