Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("AppointmentId,DiagnosId,Id")] AppliedDiagnos appliedDiagnos)
        {
            if (id != appliedDiagnos.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(appliedDiagnos);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppliedDiagnosExists(appliedDiagnos.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AppointmentId"] = new SelectList(_context.Appointments, "Id", "Id", appliedDiagnos.AppointmentId);
            ViewData["DiagnosId"]     = new SelectList(_context.Diagnoses, "Id", "Id", appliedDiagnos.DiagnosId);
            return(View(appliedDiagnos));
        }
Example #2
0
 public IActionResult Create(AppliedDiagnos appliedDiagnos)
 {
     if (ModelState.IsValid)
     {
         _db.Create(appliedDiagnos);
         _db.Save();
         return(RedirectToAction(nameof(Index)));
     }
     ViewData["AppointmentId"] = new SelectList(_context.Appointments, "Id", "Id", appliedDiagnos.AppointmentId);
     ViewData["DiagnosId"]     = _context.AppliedDiagnoses.Include(p => p.Diagnos).ToList();
     return(View(appliedDiagnos));
 }