public async Task <IActionResult> Edit(short id, [Bind("Serial,SCode,CStage,RoomNo,Date,Time")] ExamRoutine examRoutine)
        {
            if (id != examRoutine.Serial)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(examRoutine);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExamRoutineExists(examRoutine.Serial))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["CStage"] = new SelectList(_context.Class, "CStage", "CStage", examRoutine.CStage);
            ViewData["RoomNo"] = new SelectList(_context.Room, "RoomNo", "RoomNo", examRoutine.RoomNo);
            ViewData["SCode"]  = new SelectList(_context.Subject, "SCode", "SName", examRoutine.SCode);
            return(View(examRoutine));
        }
        public async Task UpdateExamRoutine(ExamRoutine examRoutine)
        {
            if (_context != null)
            {
                _context.ExamRoutine.Update(examRoutine);


                await _context.SaveChangesAsync();
            }
        }
        public async Task <int> AddExamRoutine(ExamRoutine examRoutine)
        {
            if (_context != null)
            {
                await _context.ExamRoutine.AddAsync(examRoutine);

                await _context.SaveChangesAsync();

                return(examRoutine.Id);
            }

            return(0);
        }
        public async Task <IActionResult> Create([Bind("Serial,SCode,CStage,RoomNo,Date,Time")] ExamRoutine examRoutine)
        {
            if (ModelState.IsValid)
            {
                _context.Add(examRoutine);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["CStage"] = new SelectList(_context.Class, "CStage", "CStage", examRoutine.CStage);
            ViewData["RoomNo"] = new SelectList(_context.Room, "RoomNo", "RoomNo", examRoutine.RoomNo);
            ViewData["SCode"]  = new SelectList(_context.Subject, "SCode", "SName", examRoutine.SCode);
            return(View(examRoutine));
        }