public ActionResult Chapter10()
        {
            StudentHelpers helper = new StudentHelpers();

            helper.Update_Student_Course_Status(Guid.Parse(CourseId), 100);
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            StudentHelpers helpers = new StudentHelpers();
            var            _return = helpers.Get_announcemnets();

            return(View(_return));
        }
Ejemplo n.º 3
0
        public async void GetAll_GetsAllSavedCourses()
        {
            //Arrange
            var connectionBuilder = new SqliteConnectionStringBuilder {
                DataSource = ":memory:"
            };
            var connection = new SqliteConnection(connectionBuilder.ToString());
            var options    = new DbContextOptionsBuilder <ApplicationDbContext>()
                             .UseSqlite(connection)
                             .Options;

            using var context = new ApplicationDbContext(options);
            context.Database.OpenConnection();
            context.Database.EnsureCreated();
            var studentRepository = new StudentRepository(context);
            var students          = StudentHelpers.GetStudents();

            //Act
            context.AddRange(students);
            context.SaveChanges();
            var returnedCourses = await studentRepository.GetAll();

            //Assert
            Assert.Equal(students.Count(), returnedCourses.Count());
        }
Ejemplo n.º 4
0
        public async void Insert_SavesDataAndThrowsForNullData()
        {
            //Arrange
            var connectionBuilder = new SqliteConnectionStringBuilder {
                DataSource = ":memory:"
            };
            var connection = new SqliteConnection(connectionBuilder.ToString());
            var options    = new DbContextOptionsBuilder <ApplicationDbContext>()
                             .UseSqlite(connection)
                             .Options;

            using var context = new ApplicationDbContext(options);
            context.Database.OpenConnection();
            context.Database.EnsureCreated();
            var studentRepository = new StudentRepository(context);
            var course            = StudentHelpers.GetStudent();

            //Act
            await studentRepository.Insert(course);

            var returnedStudents = await studentRepository.GetAll();

            //Assert
            Assert.Single(returnedStudents);
            await Assert.ThrowsAsync <AppUserException>(
                () => studentRepository.Insert(null));
        }
Ejemplo n.º 5
0
        public async void Update_ModifiesASavedData()
        {
            //Arrange
            var connectionBuilder = new SqliteConnectionStringBuilder {
                DataSource = ":memory:"
            };
            var connection = new SqliteConnection(connectionBuilder.ToString());
            var options    = new DbContextOptionsBuilder <ApplicationDbContext>()
                             .UseSqlite(connection)
                             .Options;

            using var context = new ApplicationDbContext(options);
            context.Database.OpenConnection();
            context.Database.EnsureCreated();
            var studentRepository = new StudentRepository(context);
            var student           = StudentHelpers.GetStudent();

            //Act
            await studentRepository.Insert(student);

            student.FirstName = "Frank";
            student.LastName  = "James";

            await studentRepository.Update(student);

            var returnedStudent = await studentRepository.Get(x => x.Id == "5");

            //Assert
            Assert.Equal("Frank", returnedStudent.FirstName);
            Assert.Equal("James", returnedStudent.LastName);
        }
Ejemplo n.º 6
0
        public async void Delete_RemovesACourseFromDatabase_ThrowsForNonNullObject()
        {
            //Arrange
            var connectionBuilder = new SqliteConnectionStringBuilder {
                DataSource = ":memory:"
            };
            var connection = new SqliteConnection(connectionBuilder.ToString());
            var options    = new DbContextOptionsBuilder <ApplicationDbContext>()
                             .UseSqlite(connection)
                             .Options;

            using var context = new ApplicationDbContext(options);
            context.Database.OpenConnection();
            context.Database.EnsureCreated();
            var studentRepository = new StudentRepository(context);
            var student           = StudentHelpers.GetStudent();

            //Act
            await studentRepository.Insert(student);

            await studentRepository.Delete(student);

            var returnedCourses = await studentRepository.GetAll();

            //Assert
            Assert.Empty(returnedCourses);
            await Assert.ThrowsAsync <ArgumentNullException>(
                () => studentRepository.Delete(null));
        }
Ejemplo n.º 7
0
        public ActionResult Record(Guid groupID)
        {
            var            id      = groupID;
            StudentHelpers helpers = new StudentHelpers();

            helpers.JoinStudentGroup(id);

            return(RedirectToAction("MyProfile"));
        }
Ejemplo n.º 8
0
 public ActionResult Editor(string editorValue)
 {
     if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
     {
         StudentHelpers sp  = new StudentHelpers();
         var            upa = sp.Update_Student_Course_Activity(Guid.Parse(CourseId));
     }
     ViewBag.editorValue = editorValue;
     return(View());
 }
Ejemplo n.º 9
0
        public ActionResult Record()
        {
            StudentHelpers   helpers = new StudentHelpers();
            var              x       = User.Identity.GetUserId();
            StudentViewModel _return = new StudentViewModel();
            var              _reg    = helpers.Add_Student_Course();

            _return = helpers.Get_All_data_Student();
            _return.Get_All_Groups     = helpers.Get_All_Groups();
            _return.StudentDetailModel = helpers.get_Student_ById(x.ToString());

            return(View(_return));
        }
Ejemplo n.º 10
0
        public async void AddCourses_AddsCoursesWithSameIdFromTheListOfSudentCourses()
        {
            //Arrange
            var connectionBuilder = new SqliteConnectionStringBuilder {
                DataSource = ":memory:"
            };
            var connection = new SqliteConnection(connectionBuilder.ToString());
            var options    = new DbContextOptionsBuilder <ApplicationDbContext>()
                             .UseSqlite(connection)
                             .Options;

            using var context = new ApplicationDbContext(options);
            context.Database.OpenConnection();
            context.Database.EnsureCreated();
            var studentRepository = new StudentRepository(context);
            var courseRepository  = new CourseRepository(context);

            var student = StudentHelpers.GetStudent();
            var courses = CourseHelpers.GetCourses();

            //Act
            foreach (var course in courses)
            {
                await courseRepository.Insert(course);
            }
            await studentRepository.Insert(student);

            await studentRepository.AddManyCourses(new List <int> {
                1, 2, 3
            }, "5");

            var numberOfCoursesAfterInsertion = (await studentRepository.GetCourses("5")).Count();

            //Assert
            Assert.Equal(3, numberOfCoursesAfterInsertion);
            await Assert.ThrowsAsync <AppUserException>(
                () => studentRepository.AddManyCourses(new List <int> {
                1, 2, 3
            }, "5"));

            await Assert.ThrowsAsync <AppUserException>(
                () => studentRepository.AddManyCourses(new List <int> {
                10, 29, 13
            }, "5"));
        }
Ejemplo n.º 11
0
        public async void Get_ReturnsACourseWithASpecificId_ThrowIfCourseDoesNotExist()
        {
            //Arrange
            var connectionBuilder = new SqliteConnectionStringBuilder {
                DataSource = ":memory:"
            };
            var connection = new SqliteConnection(connectionBuilder.ToString());
            var options    = new DbContextOptionsBuilder <ApplicationDbContext>()
                             .UseSqlite(connection)
                             .Options;

            using var context = new ApplicationDbContext(options);
            context.Database.OpenConnection();
            context.Database.EnsureCreated();
            var studentRepository = new StudentRepository(context);
            var student           = StudentHelpers.GetStudent();
            //Act
            await studentRepository.Insert(student);

            var returnedCourse = await studentRepository.Get(x => x.Id == "5");

            //Assert
            Assert.Equal("5", returnedCourse.Id);
        }
Ejemplo n.º 12
0
        public ActionResult ProcessResult(string Answer, string js, bool chk, bool chk1, bool chk2, string tag, string tag1, string tag2, string q7, string q8, string q9, string q10)
        {
            int n = 0;

            ViewBag.answer = Answer;
            if (ViewBag.answer == "True")
            {
                ViewBag.question2 = "Correct";
                n = n + 1;
            }

            ViewBag.q2 = js;
            if (ViewBag.q2 == "True")
            {
                n = n + 1;
            }
            ViewBag.q3 = chk;
            ViewBag.q4 = chk1;
            ViewBag.q5 = chk2;
            if (ViewBag.q3 == true && ViewBag.q4 == true && ViewBag.q5 != true)
            {
                n = n + 1;
            }
            ViewBag.tag = tag;
            if (ViewBag.tag == "True")
            {
                n = n + 1;
            }
            ViewBag.tag1 = tag1;
            if (ViewBag.tag1 == "True")
            {
                n = n + 1;
            }
            ViewBag.tag2 = tag2;
            if (ViewBag.tag2 == "True")
            {
                n = n + 1;
            }
            ViewBag.q7 = q7;
            if (ViewBag.q7 == "True")
            {
                n = n + 1;
            }
            ViewBag.q8 = q8;
            if (ViewBag.q8 == "True")
            {
                n = n + 1;
            }
            ViewBag.q9 = q9;
            if (ViewBag.q9 == "True")
            {
                n = n + 1;
            }
            ViewBag.q10 = q10;
            if (ViewBag.q10 == "True")
            {
                n = n + 1;
            }

            n = n * 10;
            var help = new StudentHelpers();

            help.SaveQuizResult(n, 10);

            ViewBag.result = n;
            ViewBag.color  = "StyleSheet1.css";
            return(View());
        }