コード例 #1
0
 public ActionResult ManageAdministrators()
 {
     AdminControllerAdminVM adminModel = new AdminControllerAdminVM();
     AdministratorRepository adminRepository = new AdministratorRepository();
     adminModel.administratorList = adminRepository.GetAll();
     return View(adminModel);
 }
コード例 #2
0
 public ActionResult Edit(int id, AdminControllerAdminVM model)
 {
     AdministratorRepository adminRepository = new AdministratorRepository();
     TryUpdateModel(model);
     if (ModelState.IsValid)
     {
         Administrator admin = null;
         if (adminRepository.GetAll(filter: a => a.UserName == model.UserName).FirstOrDefault() == null)
         {
             admin = new Administrator();
             admin.UserName = model.UserName;
             admin.Password = SecurityService.CreateHash(model.Password);
             admin.FirstName = model.FirstName;
             admin.LastName = model.LastName;
             admin.IsActive = true;
             adminRepository.Save(admin);
             return RedirectToAction("ManageAdministrators");
         }
         else
         {
             throw new ArgumentException("Invalid username !");
         }
     }
     return View(model);
 }
コード例 #3
0
 public ActionResult Home()
 {
     AdminControllerAdminVM model = new AdminControllerAdminVM();
     StudentRepository studentRepository = new StudentRepository();
     TeacherRepository teacherRepository = new TeacherRepository();
     CourseRepository courseRepository = new CourseRepository();
     SubjectRepository subjectRepository = new SubjectRepository();
     TitleRepository titleRepository = new TitleRepository();
     model.ActiveStudentCount = studentRepository.GetAll(filter: s => s.IsActive == true).Count;
     model.InActiveStudentCount = studentRepository.GetAll(filter: s => s.IsActive == false).Count;
     model.ActiveTeacherCount = teacherRepository.GetAll(filter: t => t.IsActive == true).Count;
     model.InActiveTeacherCount = teacherRepository.GetAll(filter: t => t.IsActive == false).Count;
     model.CourseCount = courseRepository.GetAll().Count;
     model.SubjectCount = subjectRepository.GetAll().Count;
     model.TitleCount = titleRepository.GetAll().Count();
     Administrator admin = new Administrator();
     AdministratorRepository adminRepository = new AdministratorRepository();
     admin = adminRepository.GetById(AuthenticationManager.LoggedUser.Id);
     model.FirstName = admin.FirstName;
     model.LastName = admin.LastName;
     return View(model);
 }
コード例 #4
0
 public ActionResult Edit(int id)
 {
     AdminControllerAdminVM adminModel = new AdminControllerAdminVM();
     AdministratorRepository adminRepository = new AdministratorRepository();
     if (id > 0)
     {
         Administrator admin = adminRepository.GetById(id);
         adminModel.FirstName = admin.FirstName;
         adminModel.LastName = admin.LastName;
     }
     return View(adminModel);
 }