Exemplo n.º 1
0
        public void DeleteStudentByIdTest()
        {
            //Arrange

            StudentHandler sh = new StudentHandler();
            string         actual;

            //Act

            sh.DeleteStudentById(5);

            IList <Student> testsList = sh.GetAllStudents();

            //Assert

            foreach (var student in testsList)
            {
                if (student.StudentId == 5)
                {
                    actual = "Denne findes";
                }
                else
                {
                    actual = "Findes ikke";
                }
                Assert.AreEqual("Findes ikke", actual);
            }
        }
Exemplo n.º 2
0
        // GET: Student/Edit/5
        public ActionResult Edit(int id)
        {
            StudentHandler temp        = new StudentHandler();
            Student        studentInfo = temp.GetById(id);

            return(View(studentInfo));
        }
Exemplo n.º 3
0
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here

                Student        temp    = new Student();
                StudentHandler handler = new StudentHandler();
                temp.Id        = id;
                temp.Name      = collection["Name"];
                temp.StudentID = collection["StudentID"];

                if (handler.Update(temp) == true)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Edit"));
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 4
0
        // GET: Student/Details/5
        public ActionResult Details(int id)
        {
            StudentHandler handler     = new StudentHandler();
            Student        studentInfo = handler.GetById(id);

            return(View(studentInfo));
        }
Exemplo n.º 5
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here
                Student temp = new Student();

                temp.Name      = collection["Name"];
                temp.StudentID = collection["StudentID"];

                StudentHandler handler = new StudentHandler();
                if (handler.Insert(temp) == true)
                {
                    return(RedirectToAction("Index"));
                }

                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 6
0
        public void GetAll()
        {
            IEnumerable <API.Student> students = new StudentHandler().Get(0, 10);

            Assert.IsNotNull(students);
            Assert.AreEqual(StudentDataInitializer.TestStudents.Count, students.Count());
        }
Exemplo n.º 7
0
        // GET: Student
        public ActionResult Index()
        {
            StudentHandler handler     = new StudentHandler();
            List <Student> studentList = handler.GetAll();

            return(View(studentList));
        }
        public ActionResult Create(StudentModel iList)
        {
            if (ModelState.IsValid)
            {
                StudentHandler IHandler = new StudentHandler();
                if (IHandler.InsertStudent(iList))
                {
                    ViewBag.AlertMsg = "Item Added successfully";
                    ModelState.Clear();
                }
                else
                {
                    ViewBag.AlertMsg = "Item Add Failed";
                    ModelState.Clear();
                }
            }

            ClassHandler      gHandler  = new ClassHandler();
            List <ClassModel> classlist = new List <ClassModel>();

            classlist = gHandler.GetClassList().ToList();
            classlist.Insert(0, new ClassModel()
            {
                ClassID = 0, ClassName = "Select"
            });
            ViewBag.ListOfClasses = classlist;

            return(View());
        }
        public IActionResult Index()
        {
            ViewBag.ItemList = "Student List Page";
            StudentHandler iHandler = new StudentHandler();

            ModelState.Clear();
            return(View(iHandler.GetStudentList()));
        }
Exemplo n.º 10
0
        public void GetAll_Take2()
        {
            int take = 2;
            IEnumerable <API.Student> students = new StudentHandler().Get(0, take);

            Assert.IsNotNull(students);
            Assert.AreEqual(take, students.Count());
        }
Exemplo n.º 11
0
        private static void runStudentHandler()
        {
            StudentHandler handler = new StudentHandler();

            handler.StudentOrderByFirstName();
            handler.StartsWithSameCharInFirstNameAndLastName();
            handler.AverageAgeFemaleStudents();
            handler.StudentLargestCodeByFormula();
        }
Exemplo n.º 12
0
 public void GetSingle()
 {
     API.Student student = new StudentHandler().Get(StudentDataInitializer.studentId4);
     Assert.IsNotNull(student);
     Assert.AreEqual(testStudentFirstnames, student.FirstNames);
     Assert.AreEqual(testStudentLastName, student.LastName);
     Assert.IsNull(student.Grades);
     Assert.IsNull(student.Classes);
 }
Exemplo n.º 13
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            global_student_cache = StudentHandler.initStudentCache();
        }
        public void Handle_CreateStudentCommand_WhenCalled_CreateStudent()
        {
            var studentHandler = new StudentHandler(
                _studentRepository.Object,
                _classroomRepository.Object,
                _addressRepository.Object);

            studentHandler.Handle(_createStudentCommand);

            Assert.That(_createStudentCommand.Valid, Is.True);
        }
        public void Handle_UpdateStudentCommand_WhenStudentIsNull_ReturnInvalid()
        {
            _studentRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(It.IsAny <Student>);

            var studentHandler = new StudentHandler(
                _studentRepository.Object,
                _classroomRepository.Object,
                _addressRepository.Object);
            var result = studentHandler.Handle(_updateStudentCommand);

            Assert.That(!result.Success);
        }
        public void Handle_AddClassroomCommand_WhenStudentNotExists_ThrowsException()
        {
            _studentRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Throws <Exception>();
            _classroomRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(_classroom);

            var studentHandler = new StudentHandler(
                _studentRepository.Object,
                _classroomRepository.Object,
                _addressRepository.Object);

            Assert.That(() => studentHandler.Handle(_addClassroomCommand), Throws.Exception);
        }
Exemplo n.º 17
0
        public void Insert_MissingData_Throws()
        {
            var handler = new StudentHandler();
            var student = new API.Student()
            {
                FirstNames = "testi oppilas",
            };
            var ex = Assert.Throws(typeof(DbUpdateException), () => handler.Insert(student));

            Assert.IsNotNull(ex.InnerException);
            Assert.AreEqual("SQLite Error 19: 'NOT NULL constraint failed: Students.LastName'.", ex.InnerException.Message);
        }
        public void Handle_AddAddressCommand_WhenCalled_AddAddressToStudent()
        {
            _studentRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(_student);
            _classroomRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(_classroom);

            var studentHandler = new StudentHandler(
                _studentRepository.Object,
                _classroomRepository.Object,
                _addressRepository.Object);

            studentHandler.Handle(_addAddressCommand);
            Assert.That(_addAddressCommand.Valid, Is.True);
        }
Exemplo n.º 19
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         StudentHandler handler = new StudentHandler();
         handler.DeleteById(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public void Handle_RemoveStudentCommand_RemoveStudent()
        {
            _studentRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(_student);
            _studentRepository.Setup(r => r.Remove(_student));

            var studentHandler = new StudentHandler(
                _studentRepository.Object,
                _classroomRepository.Object,
                _addressRepository.Object);

            var result = studentHandler.Handle(_removeStudentCommand);

            Assert.That(result.Success);
        }
Exemplo n.º 21
0
 public ActionResult Edit(int id, StudentModel iList)
 {
     try
     {
         StudentHandler iHnadler = new StudentHandler();
         iList.StudentID = id;
         iHnadler.UpdateStudent(iList);
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View());
     }
 }
        public void Handle_UpdateAddressCommand_UpdateAddress()
        {
            _studentRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(_student);
            _addressRepository.Setup(r => r.GetById(It.IsAny <Guid>())).Returns(_student.Address);
            _addressRepository.Setup(r => r.Update(_student.Address));

            var studentHandler = new StudentHandler(
                _studentRepository.Object,
                _classroomRepository.Object,
                _addressRepository.Object);

            var result = studentHandler.Handle(_updateAddressCommand);

            Assert.That(result.Success);
        }
Exemplo n.º 23
0
 // GET api/ricepeople/baker
 public HttpResponseMessage Get(string college)
 {
     try
     {
         if (college == null)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, new NullInputeMessage()));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, StudentHandler.getStudentsFromCollege(college)));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, new GeneralFailureMessage()));
     }
 }
Exemplo n.º 24
0
 // GET api/ricepeople?firstname=myfirstname&lastname=mylastname&college=mycollege
 public HttpResponseMessage Get(string firstname, string lastname, string college)
 {
     try
     {
         if (firstname == null || lastname == null || college == null)
         {
             return(Request.CreateResponse(HttpStatusCode.BadRequest, new NullInputeMessage()));
         }
         return(Request.CreateResponse(HttpStatusCode.OK, StudentHandler.getCandidates(firstname, lastname, college)));
     }
     catch (Exception e)
     {
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, new GeneralFailureMessage()));
     }
 }
Exemplo n.º 25
0
 public ActionResult Delete(int id)
 {
     try
     {
         StudentHandler iHandler = new StudentHandler();
         if (iHandler.DeleteStudent(id))
         {
             ViewBag.AlertMsg = "Item Deleted successfully";
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View());
     }
 }
Exemplo n.º 26
0
        public ActionResult Edit(int id)
        {
            StudentHandler iHandler    = new StudentHandler();
            StudentModel   studentItem = iHandler.GetStudentList().Find(itemmmodel => itemmmodel.StudentID == id);

            ClassHandler      gHandler  = new ClassHandler();
            List <ClassModel> classlist = new List <ClassModel>();

            classlist = gHandler.GetClassList().ToList();
            classlist.Insert(studentItem.Classes.ClassID, new ClassModel()
            {
                ClassID = 0, ClassName = "Select"
            });
            ViewBag.ListOfClasses = classlist;

            return(View(studentItem));
        }
        public List <StudentModel> GetStudentList(int id)
        {
            List <StudentModel> studentlist = new List <StudentModel>();

            if (id > 0)
            {
                StudentHandler gHandler = new StudentHandler();
                studentlist            = gHandler.GetStudentList().ToList().Where(x => x.Classes.ClassID == id).ToList();
                ViewBag.ListOfStudents = studentlist;
            }
            studentlist.Insert(0, new StudentModel()
            {
                StudentID = 0, StudentFullName = "Select"
            });

            return(studentlist);
        }
Exemplo n.º 28
0
    public void studnetAdd()    //학생수 늘리기
    {
        if (schoolClassNum > schoolBuildingNum * 30)
        {
            if (IfInt(3000) == 1)
            {
                studentGood      += 5;
                studentNormalNum += 15;
                studentBullyNum  += 10;
            }
            else
            {
                return;
            }
        }
        schoolClassNum += 1;

        StudentHandler shit = GameObject.Find("StudentHandler").GetComponent <StudentHandler>();

        shit.studentNum++;
        shit.UpdateStudentNum();
    }
Exemplo n.º 29
0
        public void AddStudentTest()
        {
            //Arrange

            StudentHandler sh = new StudentHandler();

            //var newStudent = new Student{StudentId = 100, StudentName = "TONNY"};
            sh.AddStudent(101, "Tonny");

            IList <Student> testStudetnList = sh.GetAllStudents();
            string          actual;
            string          excepted = "Tonny";

            //Act&Assert
            foreach (var s in testStudetnList)
            {
                if (s.StudentName == "Tonny")
                {
                    actual = s.StudentName;
                    Assert.AreEqual(excepted, actual);
                }
            }
        }
Exemplo n.º 30
0
        public void UpdateStudentTest()
        {
            //Arrange

            StudentHandler sh = new StudentHandler();

            sh.UpdateStudent("2", "KONNY");

            IList <Student> studentList = sh.GetAllStudents();

            string actual;
            string expected = "KONNY";

            //Act&Assert
            foreach (var stu in studentList)
            {
                if (stu.StudentId == 2)
                {
                    actual = stu.StudentName;
                    Assert.AreEqual(expected, actual);
                }
            }
        }