public async Task <IActionResult> Post([FromBody] PodcastViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid podcast model"));
            }

            var item = _mapper.Map <PodcastViewModel, Podcast>(vm);

            var isNew = string.IsNullOrEmpty(vm.Id);

            item.AppUser = _applicationUser;
            var ret = _repository.AddOrUpdate(item);

            try {
                await _unitOfWork.CompleteAsync();

                if (!isNew)
                {
                    return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret)));
                }

                // TODO: Revisit this at some stage, horribly hacky & brittle
                // TODO: This should be moved to the background cache images job
                // TODO: And ultimately handled by imageresizer when they get their f*****g docs in order
                var rawImageFileName = vm.ImageUrl?.Replace(_storageSettings.CdnUrl, string.Empty).TrimStart('/');
                if (string.IsNullOrEmpty(rawImageFileName))
                {
                    return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret)));
                }

                var parts = rawImageFileName.Split('/', 2);
                if (parts.Length != 2)
                {
                    return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret)));
                }

                await _fileUtilities.CopyRemoteFile(
                    parts[0], parts[1],
                    _fileStorageSettings.ContainerName, $"podcast/{ret.Id.ToString()}.png");

                return(Ok(_mapper.Map <Podcast, PodcastViewModel>(ret)));
            } catch (GenerateSlugFailureException) {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
        public async Task <ActionResult <string> > UploadPodcastImage(string id, IFormFile image)
        {
            _logger.LogDebug("Uploading new image");

            var podcast = await _podcastRepository.GetAsync(_applicationUser.Id, Guid.Parse(id));

            if (podcast is null)
            {
                return(NotFound());
            }
            try {
                var imageFile = await _commitImage(id, image, "podcast");

                _podcastRepository.AddOrUpdate(podcast);
                await _unitOfWork.CompleteAsync();

                return(Ok($"\"{_mapper.Map<Podcast, PodcastViewModel>(podcast).ImageUrl}\""));
            } catch (InvalidOperationException ex) {
                return(BadRequest(ex.Message));
            }
        }