// GET: TutorTypes/Edit/5 public async Task <IActionResult> Edit(int?id, TutorType model) { if (id == null) { return(NotFound()); } var tutorType = await _context.TutorType.FindAsync(id); model.TutorId = tutorType.TutorId; model.InstrumentId = tutorType.InstrumentId; model.MaxGrade = tutorType.MaxGrade; if (tutorType == null) { return(NotFound()); } List <Tutor> tutors = _context.Tutor.Include(g => g.Staff).ThenInclude(s => s.Person).ToList(); List <NameViewModel> tutorNames = tutors.Select(tutor => new NameViewModel { id = tutor.TutorId, name = tutor.Staff.Person.FirstName + " " + tutor.Staff.Person.LastName }).ToList(); ViewData["Tutor"] = new SelectList(tutorNames, "id", "name"); List <Instrument> instruments = _context.Instrument.ToList(); List <NameViewModel> instrumentNames = instruments.Select(instrument => new NameViewModel { id = instrument.InstrumentId, name = instrument.Instrument1 }).ToList(); ViewData["Instrument"] = new SelectList(instrumentNames, "id", "name"); return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("TutorTypeId,TutorTypeDesc")] TutorType tutorType) { if (id != tutorType.TutorTypeId) { return(RedirectToAction("Index", "Errors")); } if (ModelState.IsValid) { try { _context.Update(tutorType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TutorTypeExists(tutorType.TutorTypeId)) { return(RedirectToAction("Index", "Errors")); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(tutorType)); }
public TutorItem(TutorType t, bool re, TutorAim a, List <Product.ProductType> pr, int index, string t_id, int cnt, string n) { type = t; aim_ready = re; aim = a; product = pr; position_index = index; text_id = t_id; clicks = cnt; name = n; }
public async Task <IActionResult> Create([Bind("TutorTypeId,TutorTypeDesc")] TutorType tutorType) { if (ModelState.IsValid) { _context.Add(tutorType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(tutorType)); }
public async Task <IActionResult> Create([Bind("TutorId,InstrumentId,MaxGrade")] TutorType tutorType) { if (ModelState.IsValid) { _context.Add(tutorType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["InstrumentId"] = new SelectList(_context.Instrument, "InstrumentId", "Instrument1", tutorType.InstrumentId); ViewData["TutorId"] = new SelectList(_context.Tutor, "TutorId", "TutorId", tutorType.TutorId); return(View(tutorType)); }
public async Task <IActionResult> Edit(int id, [Bind("TutorId,InstrumentId,MaxGrade")] TutorType tutorType) { TutorType tutorT = await _context.TutorType.FindAsync(id); tutorT.MaxGrade = tutorType.MaxGrade; tutorT.InstrumentId = tutorType.InstrumentId; tutorT.Instrument = tutorType.Instrument; tutorT.TutorId = tutorType.TutorId; tutorT.Tutor = tutorType.Tutor; _context.Update(tutorT); if (id != tutorT.TutorTypeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tutorT); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TutorTypeExists(tutorT.TutorTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["InstrumentId"] = new SelectList(_context.Instrument, "InstrumentId", "Instrument1", tutorType.InstrumentId); ViewData["TutorId"] = new SelectList(_context.Tutor, "TutorId", "TutorId", tutorType.TutorId); return(View(tutorType)); }