示例#1
0
        public IActionResult EditTune(Tune tune)
        {
            var existingTune = _tuneRepo.GetTuneById(tune.Id);

            if (tune.Tuning != existingTune.Tuning || tune.Key != existingTune.Key)
            {
                //tuning or key has changed, need to update TC-join table and maybe collection
                CheckCollectionThenAddCollectionAndTuneCollection(tune);
            }
            _tuneRepo.EditTune(tune);
            return(NoContent());
        }
示例#2
0
        public IActionResult GetUserCollections()
        {
            UserProfile user        = GetCurrentUser();
            var         collections = _collectionRepository.GetCollectionsByUserId(user.Id);
            //var sortedCollection = collections.Select(coll => coll.TuneCollections.OrderBy(tc =>tc.Tune.Name));
            //collections themselves arent sorted
            List <CollectionWithTunes> collectionsToReturn = new List <CollectionWithTunes>();

            foreach (Collection col in collections)
            {
                var newCollection = new CollectionWithTunes(col);

                foreach (TuneCollection tc in newCollection.Collection.TuneCollections)
                {
                    newCollection.Tunes.Add(_tuneRepository.GetTuneById(tc.TuneId));
                }
                collectionsToReturn.Add(newCollection);
            }
            return(Ok(collectionsToReturn));
        }