Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("HistoryID,DoctorID,ShiftID,ShiftEndDate")] PastShifts pastShifts)
        {
            if (id != pastShifts.HistoryID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pastShifts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PastShiftsExists(pastShifts.HistoryID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorID"] = new SelectList(_context.Doctor, "DoctorID", "Phone", pastShifts.DoctorID);
            ViewData["ShiftID"]  = new SelectList(_context.Shift, "ShiftID", "ShiftID", pastShifts.ShiftID);
            return(View(pastShifts));
        }
Exemple #2
0
        public async Task <IActionResult> Create([Bind("HistoryID,DoctorID,ShiftID,ShiftEndDate")] PastShifts pastShifts)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pastShifts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorID"] = new SelectList(_context.Doctor, "DoctorID", "Phone", pastShifts.DoctorID);
            ViewData["ShiftID"]  = new SelectList(_context.Shift, "ShiftID", "ShiftID", pastShifts.ShiftID);
            return(View(pastShifts));
        }