public void Add(LegalPersonViewModel model)
        {
            if (!_personRepository.IsIdDocumentUnique(model.IdDocument))
            {
                throw new BusinessRuleException("IdDocument", "ID Document already informed.");
            }

            var person = new LegalPerson(model.CompanyName, model.TradeName, model.IdDocument)
            {
                Address = new Address(
                    model.Country, model.State, model.City, model.ZipCode, model.AddressLine1, model.AddressLine2)
            };

            _personRepository.Add(person);

            _personRepository.SaveChanges();
        }
Exemple #2
0
        public async Task Store(LegalPersonDto dto)
        {
            LegalPerson person = new LegalPerson(dto.CompanyName, dto.TradeName);

            StoreAddress(dto, person);
            StoreDocument(dto, person);

            if (!person.Validate())
            {
                NotifyDomainValidations(person.ValidationResult);
            }

            if (!_notifier.HasNotification())
            {
                _legalPersonRepository.Add(person);
                await _unitOfWork.Commit();
            }
        }