public async Task <IActionResult> Create([Bind("Id,SoftwareName,VersionNum,LinkToSoftware")] Software software) { if (ModelState.IsValid) { _context.Add(software); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(software)); }
public IActionResult SoftwareDelete(int id, int sId) { try { var professor = _context.Professor .Include(p => p.ProfessorSoftware) .Single(p => p.Id == id); var software = _context.Software .Single(s => s.Id == sId); professor.ProfessorSoftware.Remove(professor.ProfessorSoftware .Where(ProfessorSoftware => ProfessorSoftware.SoftwareId == sId) .FirstOrDefault()); _context.SaveChangesAsync(); } catch (Exception) { return(Redirect($"/Professors/Details/{id}")); } return(Redirect($"/Professors/Details/{id}")); }