Exemplo n.º 1
0
        public IActionResult SingerHasSheets(int singerId, int songId, string filter = "current")
        {
            var user = _userMapper.FindBy(u => u.UserName == User.Identity.Name).FirstOrDefault();

            if (user == null || user.SingerId != singerId)
            {
                return(RedirectToAction("AccessDenied", "Account"));
            }

            var oldInfo = _sheetsInfoMapper.FindBy(si => si.SingerId == singerId && si.SongId == songId).FirstOrDefault();

            if (oldInfo == null)
            {
                var info = new SingerSong
                {
                    SingerId = singerId,
                    SongId   = songId,
                    Status   = SheetInfoType.HasCopy
                };
                _sheetsInfoMapper.Create(info);
            }
            else if (oldInfo.Status == SheetInfoType.Ordered || oldInfo.Status == SheetInfoType.NoCopy)
            {
                oldInfo.Status = SheetInfoType.HasCopy;
                _sheetsInfoMapper.Update(oldInfo);
            }
            return(RedirectToAction("Index", "Songs", new { filter = filter }, "song" + (songId)));
        }
 public async Task AddSongForSingerAsync(string singerName, Song song)
 {
     var singer     = GetSingerAsync(singerName, false).Result;
     var singerSong = new SingerSong {
         Singer = singer, Song = song
     };
     await _context.AddAsync(singerSong);
 }