示例#1
0
        public void Create(Guid id, string title, string category, string content)
        {
            Thumbnail thumbnail = _thumbnailRepository.Get(id);

            if (thumbnail != null)
            {
                throw new Exception($"Thumbnail with this id {id} already exist!");
            }

            thumbnail = new Thumbnail(id, title, category, content);
            _thumbnailRepository.Add(thumbnail);
        }
        public IActionResult GetThumbnail([FromQuery] int v3cId, int frame)
        {
            var fileStream = _thumbnailRepository.Get(v3cId, frame);

            if (fileStream == null)
            {
                return(NotFound());
            }

            return(File(fileStream, "image/png"));
        }
        public async Task <Result <byte[], Contracts.Error> > GetAsync(string galleryName, string imageId, string tag, string formatHint)
        {
            var result = await Name.FromString(galleryName)
                         .AndThenAsync(gallery => Id.FromString(imageId)
                                       .AndThenAsync(id => Name.FromString(tag)
                                                     .AndThenAsync(t => (formatHint != null ? ImageFormat.FromExtension(formatHint).MapSuccess(s => Option.Some(s)) : Result.Success(Option.None <ImageFormat>()))
                                                                   .AndThenAsync(hint => _repository.Get(gallery, new ThumbnailId(id, t, hint))))));

            return(result.Map(s => s.Data, ErrorExtensions.ToContract));
        }