Esempio n. 1
0
        public async Task <IActionResult> GetLocationImage(Guid siteId, Guid locationId)
        {
            if (siteId == Guid.Empty)
            {
                return(BadRequest());
            }

            var item = await _businessService.FindExistingLocation(siteId, locationId);

            if (item != null)
            {
                var webRoot = _env.WebRootPath;
                _logger.LogDebug("webRoot: " + webRoot);

                var path = Path.Combine(webRoot, item.Image);
                _logger.LogDebug("path: " + path);

                string imageFileExtension = Path.GetExtension(item.Image);
                string mimetype           = GetImageMimeTypeFromImageFileExtension(imageFileExtension);

                var buffer = System.IO.File.ReadAllBytes(path);

                return(File(buffer, mimetype));
            }

            return(NotFound());
        }
Esempio n. 2
0
        public async Task <IActionResult> GetLocationById(Guid siteId, Guid locationId)
        {
            if (siteId == Guid.Empty || locationId == Guid.Empty)
            {
                return(BadRequest());
            }

            var location = await _businessService.FindExistingLocation(siteId, locationId);

            var baseUri             = _settings.LocationPicBaseUrl;
            var azureStorageEnabled = _settings.AzureStorageEnabled;

            location.FillLocationUrl(baseUri, azureStorageEnabled: azureStorageEnabled);

            if (location != null)
            {
                return(Ok(location));
            }

            return(NotFound());
        }