/// <summary> /// This is the get Edit it finds the musician in the database with the id thats passed in, /// then if its checked to see if it is null and if it is then it sends you back to the /// orchestra index, if not then it sends you to the musician Edit view. /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Edit(int id) { var musician = _repo.FindMusician(id); var orchestra = _repo.FindOrchestra(musician.OrchestraId); if (musician == null) { return(RedirectToAction("Details", "Orchestra", new { id = musician.OrchestraId })); } ViewData["Orchestra"] = orchestra; return(View(musician)); }
/// <summary> /// This brings in a musician Id finds the musician makes a new /// instrument, attached it to that musician and then sends it tho the view /// </summary> /// <param name="musicianId"></param> /// <returns>vm</returns> public IActionResult Create([Bind(Prefix = "id")] int musicianId) { var vm = new Instrument(); vm.MusicianId = musicianId; var musician = _repo.FindMusician(musicianId); ViewData["Musician"] = musician; return(View(vm)); }