Ejemplo n.º 1
0
        public ActionResult <Song> GetOne(long id)
        {
            Debug.WriteLine($"{MethodBase.GetCurrentMethod().Name} requested");

            var song = _songManager.Get(id);

            return(new ActionResult <Song>(song));
        }
        public void AddRating(Rating rating)
        {
            var song = _songRepository.Get(rating.Song.SongId);
            var user = _userRepository.Get(rating.User.UserId);

            rating.Song = null;
            rating.User = user;

            song.Ratings.Add(rating);
            song.CalculateAverageRating();

            _songRepository.SaveChanges();
        }
Ejemplo n.º 3
0
        public void AddSongToUser(UserSong userSong)
        {
            var userToUpdate = _userRepository.Get(userSong.User.UserId);
            var songToUpdate = _songRepository.Get(userSong.SongId);

            userSong.User = null;

            userToUpdate.UserSongs.Add(userSong);

            songToUpdate.IsAttached = true;

            _songRepository.SaveChanges();
            _userRepository.SaveChanges();
        }
        public IEnumerable <Song> SearchLocalSongs(string value)
        {
            var songs = _songRepository.Get();

            var query = new MusicEntityPartialSearchQuery();

            return(query.AsExpression(songs, value));
        }
Ejemplo n.º 5
0
        public Album GetBySong(long songId)
        {
            Debug.WriteLine($"{MethodBase.GetCurrentMethod().Name} requested with songId{songId}");

            var song = _songManager.Get(songId);

            return(_albumManager.GetBySong(song));
        }
Ejemplo n.º 6
0
        public IActionResult GetSongs()
        {
            var songResponse = new SongResponse();

            try
            {
                var songs   = _songRepository.Get();
                var results = Mapper.Map <IEnumerable <SongDto> >(songs);
                songResponse.Songs = results;
                return(Ok(songResponse));
            }
            catch (Exception ex)
            {
                songResponse.AlertMessage = ex.Message;
                return(BadRequest(songResponse));
            }
        }
Ejemplo n.º 7
0
        public async Task <ServiceResult <SongModel> > Get(string id)
        {
            var serviceResult = new ServiceResult <SongModel>();
            var result        = await _songRepository.Get(id);

            if (result.Success)
            {
                serviceResult.Success = true;
                serviceResult.Result  = result.Entity;
            }
            else
            {
                serviceResult.Error.Code        = ErrorStatusCode.BudRequest;
                serviceResult.Error.Description = result.Message;
            }
            return(serviceResult);
        }
Ejemplo n.º 8
0
        public void AddMusicianToSong(int songId, MusicianRegisterViewModel musician)
        {
            var recordingId = _songRepository.Get(s => s.id == songId).recordingid;

            _recordingPartyRepository.Add(new recording_party
            {
                recordingid    = recordingId,
                partyrealid    = musician.PartyRealId,
                rolecode       = musician.Role.RoleCode,
                instrumentcode = musician.Instrument.IdCode,
                updatedby      = "User", // Replace with user
                updatedon      = DateTime.Now,
                createdby      = "User",
                createdon      = DateTime.Now,
                status         = 2
            });

            _unitOfWork.Commit();
        }
Ejemplo n.º 9
0
        public Song Put(int id, SongDTO value)
        {
            Song model = ISongRepository.Get(id);

            if (value.Name != null)
            {
                model.Name = value.Name;
            }
            if (value.FitnessClassId != 0)
            {
                model.FitnessClassId = value.FitnessClassId;
            }
            if (value.Singer != null)
            {
                model.Singer = value.Singer;
            }
            if (value.Bpm != 0)
            {
                model.Bpm = value.Bpm;
            }
            return(ISongRepository.Update(model));
        }
Ejemplo n.º 10
0
 public IList <GetSongsQuery> Get()
 {
     return(_songRepository.Get());
 }
Ejemplo n.º 11
0
        public Song Delete(int id)
        {
            Song model = ISongRepository.Get(id);

            return(ISongRepository.Delete(model));
        }
Ejemplo n.º 12
0
 public ActionResult <Song> Get(int id)
 {
     return(ISongRepository.Get(id));
 }
Ejemplo n.º 13
0
 // GET: SongsController/Details/5
 public ActionResult Details(int id)
 {
     return(View(_songRepository.Get(id)));
 }