public void TestGetByIdNull()
        {
            Administrator administrator = new Administrator()
            {
                Id       = 1,
                Email    = "*****@*****.**",
                Password = "******"
            };
            List <Administrator> administrators = new List <Administrator>()
            {
                administrator,
                new Administrator()
                {
                    Id       = 2,
                    Email    = "*****@*****.**",
                    Password = "******"
                },
            };

            administrators.ForEach(s => _context.Add(s));
            _context.SaveChanges();
            var repository = new AdministratorRepository(_context);

            var result = repository.GetById(5);

            Assert.IsNull(result);
        }
        public void testGetById()
        {
            // Arrange
            int count = repo.All().Count();

            Administrator c = repo.All().FirstOrDefault();

            Assert.NotNull(c);


            // Act
            Administrator actual = repo.GetById(c.Id);

            // Assert

            Assert.NotNull(actual);
        }
示例#3
0
        public JsonResult GetUserName(int id)
        {
            AdministratorRepository adminRepository = new AdministratorRepository();
            Administrator           admin           = adminRepository.GetById(id);
            string name = admin.FirstName + " " + admin.LastName + " ?";

            return(Json(name, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public async Task <Administrator> Auth(string email, string password)
        {
            var user = await _userRepository.Auth(email, password);

            if (user == null)
            {
                return(null);
            }
            var admin = await _administratorRepository.GetById(user.UserId);

            if (admin == null)
            {
                return(null);
            }
            admin.User = user;
            return(admin);
        }
示例#5
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));
        }
示例#6
0
        public JsonResult DeleteAdministrator(int id)
        {
            AdministratorRepository adminRepository = new AdministratorRepository();

            if (id == AuthenticationManager.LoggedUser.Id)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            else
            {
                Administrator admin = adminRepository.GetById(id);
                if (admin != null)
                {
                    adminRepository.Delete(admin);
                }
                return(Json(true, JsonRequestBehavior.AllowGet));
            }
        }
示例#7
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));
        }
 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);
 }
 public JsonResult GetUserName(int id)
 {
     AdministratorRepository adminRepository = new AdministratorRepository();
     Administrator admin = adminRepository.GetById(id);
     string name = admin.FirstName + " " + admin.LastName + " ?";
     return Json(name, JsonRequestBehavior.AllowGet);
 }
 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);
 }
 public JsonResult DeleteAdministrator(int id)
 {
     AdministratorRepository adminRepository = new AdministratorRepository();
     if (id == AuthenticationManager.LoggedUser.Id)
     {
         return Json(false, JsonRequestBehavior.AllowGet);
     }
     else
     {
         Administrator admin = adminRepository.GetById(id);
         if (admin != null)
         {
             adminRepository.Delete(admin);
         }
         return Json(true, JsonRequestBehavior.AllowGet);
     }
 }