예제 #1
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());
            }
        }
예제 #2
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);
        }