Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Time,DoctorId")] DoctorOpeningHours doctorOpeningHours)
        {
            if (id != doctorOpeningHours.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(doctorOpeningHours);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DoctorOpeningHoursExists(doctorOpeningHours.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Id", doctorOpeningHours.DoctorId);
            return(View(doctorOpeningHours));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,Date,Time,DoctorId")] DoctorOpeningHours doctorOpeningHours)
        {
            if (ModelState.IsValid)
            {
                _context.Add(doctorOpeningHours);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctors, "Id", "Id", doctorOpeningHours.DoctorId);
            return(View(doctorOpeningHours));
        }