Exemplo n.º 1
0
        public IActionResult UpdateExam(ExamTypeVm ex)
        {
            ExamType ext = new ExamType()
            {
                ExamTypeId = ex.exmidVM,
                ExamName   = ex.exmnameVM
            };

            _context.ExamType.Update(ext);
            _context.SaveChanges();

            return(RedirectToAction("ExamTypeList"));
        }
Exemplo n.º 2
0
        public IActionResult UpdateExam(int id)
        {
            var e = _context.ExamType.AsNoTracking().Where(s => s.ExamTypeId == id).FirstOrDefault();

            if (e == null)
            {
                return(RedirectToAction("Error"));
            }
            ExamTypeVm ext = new ExamTypeVm()
            {
                exmnameVM = e.ExamName,
                exmidVM   = e.ExamTypeId
            };

            return(View(ext));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddExamType(ExamTypeVm ex)
        {
            if (ModelState.IsValid)
            {
                ExamType e = new ExamType()
                {
                    ExamTypeId = 0,
                    ExamName   = ex.exmnameVM
                };
                await _context.ExamType.AddAsync(e);

                await _context.SaveChangesAsync();

                return(RedirectToAction("ExamTypeList"));
            }

            return(View());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> ExamTypeList()
        {
            int count = 1;
            var Ex    = await _context.ExamType.AsNoTracking().ToListAsync();

            if (Ex.Count() == 0)
            {
                return(RedirectToAction("Error"));
            }
            List <ExamTypeVm> e = new List <ExamTypeVm>();

            foreach (var item in Ex)
            {
                ExamTypeVm ext = new ExamTypeVm()
                {
                    Serial    = count,
                    exmnameVM = item.ExamName,
                    exmidVM   = item.ExamTypeId
                };
                e.Add(ext);
                count++;
            }
            return(View(e));
        }