예제 #1
0
        // GET: Instructors
        public ActionResult Index(string _orderBy, string _sortDirection)
        {
            string currentSort = "";

            if (_sortDirection == null && _orderBy != null)
            {
                ViewData["sortDirection"] = "desc";
                currentSort = "asc";
            }
            else if (_sortDirection == null && _orderBy == null)
            {
                _orderBy    = "CohortId";
                currentSort = "asc";
                ViewData["sortDirection"] = "";
            }
            else if (_sortDirection == "asc")
            {
                ViewData["sortDirection"] = "desc";
                currentSort = "asc";
            }
            else if (_sortDirection == "desc")
            {
                ViewData["sortDirection"] = "asc";
                currentSort = "desc";
            }

            var instructors = InstructorRepository.GetInstructors(_orderBy, currentSort);

            return(View(instructors));
        }
예제 #2
0
        public List <Instructor> GetAllInstructor()
        {
            InstructorRepository instructorRepository = new InstructorRepository();
            var instructor = instructorRepository.GetAll();

            return(instructor);
        }
예제 #3
0
        public void DeleteInstructor(int id)
        {
            InstructorRepository instructorRepository = new InstructorRepository();
            Instructor           obj = instructorRepository.GetByID(id);

            instructorRepository.Delete(obj);
        }
        // GET: Instructor/Edit/5
        public ActionResult Edit(int id)
        {
            Instructor getInst            = InstructorRepository.GetSingleInstructor(id);
            IntructorCreateNewModel model = new IntructorCreateNewModel(getInst);

            return(View(model));
        }
예제 #5
0
        public List <Instructor> GetAllInstructors()
        {
            InstructorRepository repository = new InstructorRepository();
            var instr = repository.GetAll();

            return(instr);
        }
        public void created_course_is_assigned_to_correct_instructor()
        {
            //using (var Uow = new MOOCollab2UOW())
            using (var Uow = new TestDb())
            {
                //Arrange
                var courseRepo = new CourseRepository(Uow);
                var instructorRepo = new InstructorRepository(Uow);
                var testInstructor = instructorRepo.Find(1);

                courseRepo.Create(new Course
                {
                    OwnerId = 1,//course to instructor with Id of one
                    Title = "Test",
                    Resume = "Argh",//test text
                    Status = true
                });
                courseRepo.SaveChanges();
            }

            //using (var Uow = new MOOCollab2UOW())
            using (var Uow = new TestDb())
            {
                //Arrange
                var instructorRepo = new InstructorRepository(Uow);

                //Act
                var instructor = instructorRepo.FindAll()
                                .Include(i => i.Courses)
                                .FirstOrDefault(i => i.Id == 1);
                //assert  //Check if instructor has the new course
                Assert.IsNotNull(instructor.Courses.FirstOrDefault(c => c.Resume == "Argh"));
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            StudentRepository.SetConfig(Configuration);
            CohortRepository.SetConfig(Configuration);
            InstructorRepository.SetConfig(Configuration);
            ExerciseRepository.SetConfig(Configuration);

            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
예제 #8
0
        public UnitOfWork(TitanDbContext context)
        {
            var sessionId = Guid.NewGuid();

            _context    = context;
            Instructors = new InstructorRepository(_context);
            Courses     = new CourseRepository(_context);
        }
예제 #9
0
        public void AddDepartments(Departments entity)
        {
            DepartmentsRepository departmentsRepository = new DepartmentsRepository();
            InstructorRepository  instructorRepository  = new InstructorRepository();
            Instructor            instructor            = instructorRepository.PrintOne(entity.InstructorID);

            entity.Instructor = instructor;
            departmentsRepository.Add(entity);
        }
예제 #10
0
        public void AddInstructor(Instructor entity)
        {
            InstructorRepository instructorRepository = new InstructorRepository();
            PeopleRepository     peopleRepository     = new PeopleRepository();
            People people = peopleRepository.GetByID(entity.ID);

            entity.People = people;
            instructorRepository.Add(entity);
        }
예제 #11
0
        // GET: Instructor
        public ActionResult Index()
        {
            ContosoContext       cc = new ContosoContext();
            InstructorRepository ir = new InstructorRepository(cc);
            InstructorService    instructorService = new InstructorService(ir);
            var instructor = instructorService.GetAllInstructors();

            return(View(instructor));
        }
예제 #12
0
 public UnitOfWork(ExamContext context)
 {
     _context    = context;
     Courses     = new CourseRepository(_context);
     Questions   = new QuestionRepository(_context);
     Exams       = new ExamRepository(_context);
     Students    = new StudentRepository(_context);
     Instructors = new InstructorRepository(_context);
 }
예제 #13
0
 public UnitOfWork(ApplicationDbContext context, IPropertyMappingService propertyMappingService)
 {
     this.context = context;
     this.propertyMappingService = propertyMappingService;
     DogRepository            = new DogRepository(context, propertyMappingService);
     InstructorRepository     = new InstructorRepository(context);
     TaskRepository           = new  TaskRepository(context);
     TaskEngagementRepository = new TaskEngagementRepository(context);
     TrainingCourseRepository = new TrainingCourseRepository(context);
 }
예제 #14
0
        // GET: Instructor
        public async Task <ActionResult> Index()
        {
            IEnumerable <Instructor> instructors = null;

            using (_instructorRepository = new InstructorRepository())
            {
                instructors = await _instructorRepository.GetListAsync();
            }
            return(View(instructors));
        }
예제 #15
0
 public ActionResult Delete(int id, IFormCollection collection)
 {
     if (InstructorRepository.DeleteInstructor(id))
     {
         return(RedirectToAction(nameof(Index)));
     }
     else
     {
         return(RedirectToAction(nameof(Details), new { id = id }));
     }
 }
예제 #16
0
        public async Task <IActionResult> Get(int id)
        {
            Instructor dbInstructor = await InstructorRepository.GetAsync(id);

            if (dbInstructor == null)
            {
                return(BadRequest());
            }

            return(Ok(dbInstructor));
        }
예제 #17
0
 public ActionResult Create(InstructorCreateViewModel viewModel)
 {
     try
     {
         InstructorRepository.CreateInstructor(viewModel);
         return(View(viewModel));
     }
     catch
     {
         return(View());
     }
 }
예제 #18
0
        public async Task <ActionResult> SpecificInstructor(int id)
        {
            IEnumerable <Instructor> result = null;

            using (_instructorRepository = new InstructorRepository())
            {
                var allInstructors = await _instructorRepository.GetListWithCoursesAsync();

                result = from x in allInstructors where x.InstructorID == id select x;
            }
            return(View(result.ToList()[0]));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         InstructorRepository.DeleteInstructor(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(RedirectToAction(nameof(Details)));
     }
 }
 public ActionResult Delete(int id)
 {
     try
     {
         InstructorRepository.DeleteInstructor(id);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
 public ActionResult Create(IntructorCreateNewModel model)
 {
     try
     {
         int id = InstructorRepository.InsertInstructor(model.Instructor);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
예제 #22
0
        public async Task <ActionResult> InstructorIndex()
        {
            Instructor        instructor = null;
            List <Instructor> res        = new List <Instructor>();

            using (_instructorRepository = new InstructorRepository())
            {
                ViewBag.Enrollments = await _instructorRepository.GetInstructorEnrollmentsAsync(HttpContext.User.Identity.GetUserId());

                instructor = await _instructorRepository.GetAsync(HttpContext.User.Identity.GetUserId());
            }
            return(View(instructor));
        }
예제 #23
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context    = context;
     Instructors = new InstructorRepository(_context);
     InstructorConfigrationKeys = new InstructorConfigrationKeyRepository(_context);
     Students = new StudentRepository(_context);
     StudentConfigrationKeys = new StudentConfigrationKeyRepository(_context);
     ITIBranchs = new ITIBranchRepository(_context);
     ITIBranchConfigrationKeys = new ITIBranchConfigrationKeyRepository(_context);
     ITIBranchConfigrations    = new ITIBranchConfigrationsRepository(_context);
     StudentConfigrations      = new StudentConfigrationsRepository(_context);
     InstructorConfigration    = new InstructorConfigrationRepository(_context);
 }
예제 #24
0
 public ActionResult Edit(int id, InstructorEditViewModel viewModel)
 {
     try
     {
         InstructorRepository.EditInstructor(id, viewModel);
         return(View(viewModel));
     }
     catch
     {
         viewModel.Cohorts = GetAllCohorts();
         return(View(viewModel));
     }
 }
예제 #25
0
 public ActionResult Edit(int id, [FromForm] InstructorEditViewModel model)
 {
     try
     {
         model.instructor.Id = id;
         InstructorRepository.UpdateInstructor(model.instructor);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         return(View(model));
     }
 }
        public ActionResult Edit(int id, [FromForm] IntructorCreateNewModel instructorModel)
        {
            try
            {
                InstructorRepository.UpdateInstructor(instructorModel.Instructor);
                // TODO: Add update logic here

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
예제 #27
0
 public RentingService(RentDbContext db) : base()
 {
     DbContext       = db;
     Companies       = new CompanyRepository(db);
     Rentals         = new RentalRepository(db);
     Instructors     = new InstructorRepository(db);
     Languages       = new LanguageRepository(db);
     LanguageLevels  = new LanguageLevelRepository(db);
     Tickets         = new TicketRepository(db);
     WageRates       = new WageRateRepository(db);
     Expertises      = new ExpertiseRepository(db);
     ExpertiseLevels = new ExpertiseLevelRepository(db);
     Courses         = new CourseRepository(db);
 }
예제 #28
0
        static void Main(string[] args)
        {
            DbContextOptions <MyDbContext> options = new DbContextOptionsBuilder <MyDbContext>().UseMySql("Server=localhost;Port=3306;Database=weqe;Uid=root;Pwd=parolagelecek;").Options;

            MyDbContext myDbContext = new MyDbContext(options);


            IInstructorRepository instructorRepository = new InstructorRepository(myDbContext);

            Instructor instructor = instructorRepository.FindById(1);

            System.Console.WriteLine(instructor.FirstName);
            System.Console.WriteLine(instructor.LastName);
            System.Console.WriteLine(instructor.Courses[0].Instructor.FirstName);
        }
예제 #29
0
        public async Task <ActionResult> Delete(int id)
        {
            Instructor instructor = await InstructorRepository.GetAsync(id);

            if (instructor == null)
            {
                return(NotFound());
            }

            if (!InstructorRepository.Delete(instructor))
            {
                throw new Exception($"Deleting a instructor {id} failed on save.");
            }
            return(NoContent());
        }
예제 #30
0
        static void Main(string[] args)
        {
            InstructorRepository intructorRepo = new InstructorRepository();
            List <string>        intructors    = instructorRepo.GetIntructors();

            var one   = "Josh";
            var two   = "Paul";
            var three = "Ransford";
            var four  = "Kenn";

            foreach (string s in intructors)
            {
                Console.WriteLine(s);
            }

            Console.ReadLine();
        }
        public UnitOfWork(ActiveLearningContext context)
        {
            _context = context;

            Admins   = new AdminRepository(_context);
            Chats    = new ChatRepository(_context);
            Contents = new ContentRepository(_context);
            Courses  = new CourseRepository(_context);
            Instructor_Course_Maps = new Instructor_Course_MapRepository(_context);
            Instructors            = new InstructorRepository(_context);
            QuizAnswers            = new QuizAnswerRepository(_context);
            QuizOptions            = new QuizOptionRepository(_context);
            QuizQuestions          = new QuizQuestionRepository(_context);
            Student_Course_Maps    = new Student_Course_MapRepository(_context);
            Students = new StudentRepository(_context);
            Users    = new UserRepository(_context);
        }