//Scorepiece is posted, update any changes to the record
 public async Task <IActionResult> EditScorePiece(int id, [Bind("ScoreId", "Instruments", "IndexedPieces", "names")] ScorePieces scorepiece)
 {
     if (ModelState.IsValid)
     {
         //Update the record.
         try
         {
             scorepiece.ScoreId = id;
             _context.Update(scorepiece);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!ScorePieceExists(scorepiece.ScoreId))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(View(scorepiece));
     }
     //Change view to the original score index screen
     return(View("Index", "Score"));
 }
Exemple #2
0
        public async Task <IActionResult> AddToScore(int p, int s)
        {
            ScorePieces scorePiece = new ScorePieces {
                ScoreId = s, PieceId = p
            };
            await _context.ScorePieces.AddAsync(scorePiece);

            await _context.SaveChangesAsync();

            return(RedirectToAction("Index", new { id = s }));
        }
        //Creates new ScorePiece object to add pieces with the corresponding scoreId
        //Saves to the database
        //Add Model State checking
        public async Task <IActionResult> AddPieces(string id)
        {
            int         sid        = Convert.ToInt32(id);
            ScorePieces scorepiece = new ScorePieces()
            {
                ScoreId = sid
            };

            _context.ScorePieces.Add(scorepiece);
            await _context.SaveChangesAsync();

            return(View(scorepiece));
        }