Beispiel #1
0
        public ActionResult updateAdminProfile(AdminModel admin)
        {
            if (Session["username"] != null && Session["role"].Equals("admin"))
            {
                var adminInDb = _context.adminDb.Single(p => p.id == admin.id);
                adminInDb.name     = admin.name;
                adminInDb.phone    = admin.phone;
                adminInDb.username = admin.username;

                _context.SaveChanges();
                return(RedirectToAction("editAdminProfile", new RouteValueDictionary(new { Controller = "Admin", Action = "editAdminProfile", id = admin.id })));
            }

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult updateProfessorProfile(ProfessorModel professor)
        {
            if (Session["username"] != null && Session["role"].Equals("professor"))
            {
                var professorInDb = _context.professorDb.Single(p => p.id == professor.id);
                professorInDb.name     = professor.name;
                professorInDb.phone    = professor.phone;
                professorInDb.e_mail   = professor.e_mail;
                professorInDb.address  = professor.address;
                professorInDb.gender   = professor.gender;
                professorInDb.age      = professor.age;
                professorInDb.username = professor.username;

                _context.SaveChanges();
                return(RedirectToAction("editProfessorProfile", new RouteValueDictionary(new { Controller = "Professor", Action = "editProfessorProfile", id = professor.id })));
            }

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult updateStudentProfile(StudentModel student)
        {
            if (Session["username"] != null && Session["role"].Equals("student"))
            {
                var studentInDb = _context.studentDb.Single(p => p.id == student.id);
                studentInDb.name     = student.name;
                studentInDb.phone    = student.phone;
                studentInDb.e_mail   = student.e_mail;
                studentInDb.address  = student.address;
                studentInDb.gender   = student.gender;
                studentInDb.age      = student.age;
                studentInDb.username = student.username;

                _context.SaveChanges();
                return(RedirectToAction("editStudentProfile", new RouteValueDictionary(new { Controller = "Student", Action = "editStudentProfile", id = student.id })));
            }

            return(RedirectToAction("Login", "Home"));
        }