public async Task ImportPersonAsync(ImportPersonModel model) { var nationalIdentificationNumber = string.IsNullOrWhiteSpace(model.NationalIdentificationNumber) ? default(string) : model.NationalIdentificationNumber.Trim().ToUpper(); var command = new ImportPersonCommand( model.UserId, model.PersonId, model.RegistrationDate, model.FirstName, model.LastName, nationalIdentificationNumber, model.VatNumber, model.Address?.Address, model.Address?.City, model.Address?.PostalCode, model.Address?.Province, model.Address?.Country, model.PhoneNumber, model.MobileNumber, model.FaxNumber, model.WebsiteAddress, model.EmailAddress, model.InstantMessaging ); await Bus.Send(command); }
public async Task Handle(ImportPersonCommand message) { var country = string.IsNullOrWhiteSpace(message.Address) || !string.IsNullOrWhiteSpace(message.Country) ? message.Country : _defaultCountryResolver.GetDefaultCountry(); var person = Person.Factory.CreateNewEntryByImport(message.PersonId, message.RegistrationDate, message.FirstName, message.LastName, message.NationalIdentificationNumber, message.VatNumber, message.Address, message.City, message.PostalCode, message.Province, country, message.PhoneNumber, message.MobileNumber, message.FaxNumber, message.WebsiteAddress, message.EmailAddress, message.InstantMessaging); await _repository.SaveAsync(person); this.Data.PersonId = person.Id; }
public Task Handle(ImportPersonCommand message) { return(Task.Factory.StartNew(() => { var country = string.IsNullOrWhiteSpace(message.Address) || !string.IsNullOrWhiteSpace(message.Country) ? message.Country : _defaultCountryResolver.GetDefaultCountry(); var person = Person.Factory.CreateNewEntryByImport(message.PersonId, message.FirstName, message.LastName, message.NationalIdentificationNumber, message.VatNumber, message.Address, message.City, message.PostalCode, message.Province, country, null, null, null, null, null, null); _repository.Save <Person>(person); this.Data.PersonId = person.Id; })); }
public Task Handle(ImportPersonCommand message) { return(Task.Factory.StartNew(() => { var person = Person.Factory.CreateNewEntryByImport(message.PersonId, message.FirstName, message.LastName, message.NationalIdentificationNumber, message.VatNumber); if (!!string.IsNullOrWhiteSpace(message.Address) && !string.IsNullOrWhiteSpace(message.City)) { person.SetAddress(message.Address, message.City, message.PostalCode, message.Province, message.Country); } _repository.Save <Person>(person); this.Data.PersonId = person.Id; })); }
public void Ctor_should_properly_initialise_instance() { var personId = Guid.NewGuid(); var firstName = "Martin"; var lastName = "Gore"; var nationalIdentificationNumber = "FAKE"; var vatNumber = "123"; var address = "Via Torino 51"; var city = "Milan"; var postalCode = "20123"; var province = "MI"; var country = "Italy"; var phoneNumber = "405040420"; var mobileNumber = "527452042"; var faxNumber = "0405763872"; var websiteAddress = "http://www.info.com"; var emailAddress = "*****@*****.**"; var instantMessaging = "@im"; var sut = new ImportPersonCommand(personId, DateTime.Now, firstName, lastName, nationalIdentificationNumber, vatNumber, address, city, postalCode, province, country, phoneNumber, mobileNumber, faxNumber, websiteAddress, emailAddress, instantMessaging); Assert.Equal(personId, sut.PersonId); Assert.Equal(firstName, sut.FirstName); Assert.Equal(lastName, sut.LastName); Assert.Equal(nationalIdentificationNumber, sut.NationalIdentificationNumber); Assert.Equal(vatNumber, sut.VatNumber); Assert.Equal(address, sut.Address); Assert.Equal(city, sut.City); Assert.Equal(postalCode, sut.PostalCode); Assert.Equal(province, sut.Province); Assert.Equal(country, sut.Country); Assert.Equal(phoneNumber, sut.PhoneNumber); Assert.Equal(mobileNumber, sut.MobileNumber); Assert.Equal(faxNumber, sut.FaxNumber); Assert.Equal(websiteAddress, sut.WebsiteAddress); Assert.Equal(emailAddress, sut.EmailAddress); Assert.Equal(instantMessaging, sut.InstantMessaging); }