private bool ArtAndCollectionExist(AddToArtCollection artCollection)
        {
            bool artExists        = _context.Art.Any(a => a.ArtId == artCollection.ArtId);
            bool collectionExists = _context.Collections.Any(c => c.CollectionId == artCollection.CollectionId);

            return(artExists && collectionExists);
        }
        public async Task <bool> AddToCollection(AddToArtCollection artCollection)
        {
            if (ArtExistsInCollection(artCollection))
            {
                return(false);
            }
            if (!ArtAndCollectionExist(artCollection))
            {
                return(false);
            }

            ArtCollection newAddition = new ArtCollection
            {
                ArtId        = artCollection.ArtId,
                CollectionId = artCollection.CollectionId
            };

            _context.ArtCollections.Add(newAddition);
            await _context.SaveChangesAsync();

            return(true);
        }
 private bool ArtExistsInCollection(AddToArtCollection artCollection)
 {
     return(_context.ArtCollections.Any(ac => ac.ArtId == artCollection.ArtId && ac.CollectionId == artCollection.CollectionId));
 }
 public async Task <ActionResult> AddToCollection(int profileId, int collectionId, [FromBody] AddToArtCollection artCollection)
 {
     if (!profileCollectionRepository.CollectionExistsForProfile(profileId, collectionId))
     {
         return(BadRequest());
     }
     if (collectionId != artCollection.CollectionId)
     {
         return(BadRequest());
     }
     if (!await profileCollectionRepository.AddToCollection(artCollection))
     {
         return(BadRequest());
     }
     return(NoContent());
 }