public async Task <ActionResult> Delete(int instrumentId) { string UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); TalentByInstrument delete = _context.TalentByInstruments.Where(x => x.UserId == UserId).FirstOrDefault(); _context.TalentByInstruments.Remove(delete); await _context.SaveChangesAsync(); return(RedirectToAction("Create", "TalentByInstrument")); }
public async Task <ActionResult> Create(InstrumentViewModel InstrumentData) { var talentByInstrument1 = new TalentByInstrument(); string UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); talentByInstrument1.UserId = UserId; talentByInstrument1.InstrumentId = InstrumentData.CreatedInstrument; _context.TalentByInstruments.Add(talentByInstrument1); await _context.SaveChangesAsync(); try { // TODO: Add insert logic here return(RedirectToAction("Create", "TalentByInstrument")); } catch { return(View()); } }