public async Task <LocationViewModel> ProvisionLocationAsync(ProvisionLocationCommand provisionLocationCommand) { var existingSite = _siteRepository.Find(provisionLocationCommand.SiteId); //await _eventStoreSession.Get<Site>(provisionLocationCommand.SiteId); ContactInformation contactInformation = new ContactInformation(provisionLocationCommand.ContactName, provisionLocationCommand.PrimaryTelephone, provisionLocationCommand.SecondaryTelephone, provisionLocationCommand.EmailAddress); var location = existingSite.ProvisionLocation(provisionLocationCommand.Name, provisionLocationCommand.Description, contactInformation); //await _eventStoreSession.Add<Location>(location); //await _eventStoreSession.Commit(); //var site = _siteRepository.Find(provisionLocationCommand.SiteId); //site.ProvisionLocation(provisionLocationCommand.Name, provisionLocationCommand.Description, contactInformation); //_siteRepository //_siteRepository.UnitOfWork.Commit(); await _businessIntegrationEventService.PublishThroughEventBusAsync(new LocationCreatedEvent( location.Id, provisionLocationCommand.SiteId, provisionLocationCommand.Name, provisionLocationCommand.Description, contactInformation.ContactName, contactInformation.EmailAddress, contactInformation.PrimaryTelephone, contactInformation.SecondaryTelephone ) ); return(_mapper.Map <LocationViewModel>(location)); }
private ProvisionLocationCommand BuildLocationCmd(Guid siteId, string name, string description ) { var command = new ProvisionLocationCommand { Name = name, Description = description, ContactName = "test", EmailAddress = "*****@*****.**", PrimaryTelephone = "123-123-1234", SecondaryTelephone = "123-123-1234", SiteId = siteId }; return(command); }
public async Task <IActionResult> ProvisionLocation([FromBody] ProvisionLocationRequest request ) { if (!ModelState.IsValid) { return((IActionResult)BadRequest()); } var command = new ProvisionLocationCommand { Name = request.Name, Description = request.Description, ContactName = request.ContactName, EmailAddress = request.EmailAddress, PrimaryTelephone = request.PrimaryTelephone, SecondaryTelephone = request.SecondaryTelephone, SiteId = request.SiteId }; var location = await _businessInformationService.ProvisionLocationAsync(command); return((IActionResult)Ok(location)); }