public async Task <IActionResult> Edit(int id, [Bind("DoctorShiftID,DoctorID,ShiftID")] DoctorShifts doctorShifts) { if (id != doctorShifts.DoctorShiftID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(doctorShifts); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DoctorShiftsExists(doctorShifts.DoctorShiftID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DoctorID"] = new SelectList(_context.Doctor, "DoctorID", "Name", doctorShifts.DoctorID); ViewData["ShiftID"] = new SelectList(_context.Shift, "ShiftID", "Name", doctorShifts.ShiftID); return(View(doctorShifts)); }
public async Task <IActionResult> Create([Bind("DoctorShiftID,DoctorID,ShiftID")] DoctorShifts doctorShifts) { if (ModelState.IsValid) { _context.Add(doctorShifts); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["DoctorID"] = new SelectList(_context.Doctor, "DoctorID", "Name", doctorShifts.DoctorID); ViewData["ShiftID"] = new SelectList(_context.Shift, "ShiftID", "Name", doctorShifts.ShiftID); return(View(doctorShifts)); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { DoctorShifts doctorshift = (DoctorShifts)validationContext.ObjectInstance; /*case "Manha": * case "Morning": * break; * case "Tarde": * case "Afternoon": * break; * case "Noite": * case "Night": * break;*/ return(ValidationResult.Success); }