示例#1
0
        public async Task DeleteImageFromCatalogAsync(UpdateImageCatalogDto imageCatalogDto)
        {
            ImageCatalog imageCatalog = await _repository.GetImageCatalogByIdFKAsync(imageCatalogDto.ImageId, imageCatalogDto.CatalogId);

            _repository.DeleteImageFromCatalog(imageCatalog);
            await _context.SaveChangesAsync();
        }
示例#2
0
        public async Task AddImageToCatalogAsync(UpdateImageCatalogDto imageCatalogDto)
        {
            ImageCatalog imageCatalog = new ImageCatalog()
            {
                ImageId   = imageCatalogDto.ImageId,
                CatalogId = imageCatalogDto.CatalogId
            };

            _repository.AddImageToCatalog(imageCatalog);
            await _context.SaveChangesAsync();
        }
        public async Task <ActionResult <ImageCatalog> > Post(ImageCatalog catalog)
        {
            if (catalog == null)
            {
                return(BadRequest());
            }

            db.ImageCatalog.Add(catalog);
            await db.SaveChangesAsync();

            return(Ok(catalog));
        }
        public async Task <ActionResult <ImageCatalog> > Delete(int id)
        {
            ImageCatalog catalog = db.ImageCatalog.FirstOrDefault(x => x.Id == id);

            if (catalog == null)
            {
                return(NotFound());
            }
            db.ImageCatalog.Remove(catalog);
            await db.SaveChangesAsync();

            return(Ok(catalog));
        }
示例#5
0
        public async Task DeleteImageFromCatalogAsyncCallsMethodOfRepository_And_SavesChanges()
        {
            var imageCatalog = new UpdateImageCatalogDto()
            {
                CatalogId = 1,
                ImageId   = 1
            };
            ImageCatalog ic = new ImageCatalog();

            await _service.DeleteImageFromCatalogAsync(imageCatalog);

            _catalogRepositoryMock.Verify(r => r.DeleteImageFromCatalog(It.IsAny <ImageCatalog>()), Times.Once);
            _dbContextMock.Verify(r => r.SaveChangesAsync(CancellationToken.None), Times.Once);
        }
        public async Task <ActionResult <ImageCatalog> > Put(ImageCatalog catalog)
        {
            if (catalog == null)
            {
                return(BadRequest());
            }
            if (!db.Images.Any(x => x.Id == catalog.Id))
            {
                return(NotFound());
            }

            db.Update(catalog);
            await db.SaveChangesAsync();

            return(Ok(catalog));
        }
 public void AddImageToCatalog(ImageCatalog imageCatalog)
 {
     _context.ImageCatalogs.Add(imageCatalog);
 }
 public void DeleteImageFromCatalog(ImageCatalog imageCatalog)
 {
     _context.ImageCatalogs.Remove(imageCatalog);
 }