Beispiel #1
0
        public async Task <OperationResult <Book> > AddImageAsync(Book item, byte[] image)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            if (image == null || !image.Any())
            {
                throw new ArgumentNullException(nameof(image));
            }

            var result = await _repository.GetAsync(item.Id);

            item = result.Entity;
            if (item == null)
            {
                return(new OperationResult <Book>(new [] { "Library item not found in database." }));
            }

            //item.Pictures = item.Pictures ?? new List<Picture>();
            //item.Pictures.Add(new Picture
            //{
            //    Bytes = image,
            //    Book = item,
            //});

            return(await _repository.UpdateAsync(item));
        }
 public Task <OperationResult <Book> > UpdateAsync(Book item)
 {
     return(_libraryItemRepository.UpdateAsync(item));
 }