public IActionResult Preferences([Bind("FirstName,LastName,UserName,Password,Email")] InstructorM instructor)
        {
            /*var PassID = (int)HttpContext.Session.GetInt32(SessionLoggedID);
             * if (PassID != instructor.ID)
             * {
             *  return NotFound();
             * }*/
            var PassID = HttpContext.Session.GetInt32(SessionLoggedID);

            instructor.ID = (int)PassID;

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructor);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorExists(instructor.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                ViewBag.Success = "Preferences Updated";
                return(View("InstructorIndex"));
            }
            ViewBag.Error = "Model State Invalid";
            return(View("InstructorIndex"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("StudentID,FirstName,LastName,InstructorID")] StudentM student)
        {
            if (id != student.StudentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.StudentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(student));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,LastName,FirstName,UserName,Password,Email")] InstructorM instructor)
        {
            if (id != instructor.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InstructorExists(instructor.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(instructor));
        }