public SupplementalFormsController(IProcessQueries queryProcessor , IConsumePlaceFinder placeFinder , IHandleCommands<UpdateEstablishment> updateEstablishment , IUnitOfWork unitOfWork ) { _queryProcessor = queryProcessor; _placeFinder = placeFinder; _updateEstablishment = updateEstablishment; _unitOfWork = unitOfWork; }
public SupplementalFormsController(IProcessQueries queryProcessor , IConsumePlaceFinder placeFinder , IHandleCommands <UpdateEstablishment> updateEstablishment , IUnitOfWork unitOfWork ) { _queryProcessor = queryProcessor; _placeFinder = placeFinder; _updateEstablishment = updateEstablishment; _unitOfWork = unitOfWork; }
public HealthController(IProcessQueries queryProcessor , ICommandEntities entities , IUnitOfWork unitOfWork , IConsumePlaceFinder placeFinder , IHandleCommands <UpdateEstablishmentHierarchiesCommand> updateEstablishmentHierarchy , IHandleCommands <UpdateInstitutionalAgreementHierarchiesCommand> updateInstitutionalAgreementHierarchy , IHandleCommands <CreateEstablishment> createEstablishment , IHandleCommands <UpdateEstablishment> updateEstablishment ) { _queryProcessor = queryProcessor; _entities = entities; _unitOfWork = unitOfWork; _placeFinder = placeFinder; _updateEstablishmentHierarchy = updateEstablishmentHierarchy; _updateInstitutionalAgreementHierarchy = updateInstitutionalAgreementHierarchy; _createEstablishment = createEstablishment; _updateEstablishment = updateEstablishment; }
private void Build(int retryCount) { _queryProcessor = ServiceProviderLocator.Current.GetService<IProcessQueries>(); _updateEstablishment = ServiceProviderLocator.Current.GetService<IHandleCommands<UpdateEstablishment>>(); _unitOfWork = ServiceProviderLocator.Current.GetService<IUnitOfWork>(); _placeFinder = ServiceProviderLocator.Current.GetService<IConsumePlaceFinder>(); try { var establishment = _queryProcessor.Execute(new GetEstablishmentByIdQuery(_establishmentId)); if (!establishment.Location.Center.HasValue) return; var latitude = establishment.Location.Center.Latitude; var longitude = establishment.Location.Center.Longitude; if (!latitude.HasValue || !longitude.HasValue) return; var result = _placeFinder.Find(new PlaceByCoordinates(latitude.Value, longitude.Value)).SingleOrDefault(); if (result == null) return; if (!result.WoeId.HasValue) { throw new NotSupportedException(string.Format( "Could not find WOE ID for coordinates {0},{1}", latitude, longitude)); } //var place = _placeFactory.FromWoeId(result.WoeId.Value); var place = _queryProcessor.Execute( new GetPlaceByWoeIdQuery { WoeId = result.WoeId.Value, }); var places = place.Ancestors.OrderByDescending(n => n.Separation).Select(a => a.Ancestor).ToList(); places.Add(place); var command = new UpdateEstablishment { Id = establishment.RevisionId, PlaceIds = places.Select(p => p.RevisionId).ToArray(), }; _updateEstablishment.Handle(command); //_establishment.Location.Places.Clear(); //_establishment.Location.Places = places; //_objectCommander.Update(_establishment, true); //_entities.Update(_establishment); _unitOfWork.SaveChanges(); } catch (Exception ex) { var exceptionLogger = ServiceProviderLocator.Current.GetService<ILogExceptions>(); exceptionLogger.LogException(ex); if (ex is NotSupportedException) { retryCount = 3; } if (retryCount < 2) { Build(++retryCount); } } }
public HandleWoeIdByCoordinatesCommand(IConsumePlaceFinder placeFinder) { _placeFinder = placeFinder; }
public PlaceFinderContainer(string consumerKey, string consumerSecret) { _consumerKey = consumerKey; _consumerSecret = consumerSecret; _client = new PlaceFinderClient(); }
private void Build(int retryCount) { _queryProcessor = ServiceProviderLocator.Current.GetService <IProcessQueries>(); _updateEstablishment = ServiceProviderLocator.Current.GetService <IHandleCommands <UpdateEstablishment> >(); _unitOfWork = ServiceProviderLocator.Current.GetService <IUnitOfWork>(); _placeFinder = ServiceProviderLocator.Current.GetService <IConsumePlaceFinder>(); try { var establishment = _queryProcessor.Execute(new GetEstablishmentByIdQuery(_establishmentId)); if (!establishment.Location.Center.HasValue) { return; } var latitude = establishment.Location.Center.Latitude; var longitude = establishment.Location.Center.Longitude; if (!latitude.HasValue || !longitude.HasValue) { return; } var result = _placeFinder.Find(new PlaceByCoordinates(latitude.Value, longitude.Value)).SingleOrDefault(); if (result == null) { return; } if (!result.WoeId.HasValue) { throw new NotSupportedException(string.Format( "Could not find WOE ID for coordinates {0},{1}", latitude, longitude)); } //var place = _placeFactory.FromWoeId(result.WoeId.Value); var place = _queryProcessor.Execute( new GetPlaceByWoeIdQuery { WoeId = result.WoeId.Value, }); var places = place.Ancestors.OrderByDescending(n => n.Separation).Select(a => a.Ancestor).ToList(); places.Add(place); var command = new UpdateEstablishment { Id = establishment.RevisionId, PlaceIds = places.Select(p => p.RevisionId).ToArray(), }; _updateEstablishment.Handle(command); //_establishment.Location.Places.Clear(); //_establishment.Location.Places = places; //_objectCommander.Update(_establishment, true); //_entities.Update(_establishment); _unitOfWork.SaveChanges(); } catch (Exception ex) { var exceptionLogger = ServiceProviderLocator.Current.GetService <ILogExceptions>(); exceptionLogger.LogException(ex); if (ex is NotSupportedException) { retryCount = 3; } if (retryCount < 2) { Build(++retryCount); } } }