public int Assign(CourseToTeacherModel courseToTeacher)
        {
            query = "update TeacherTable set RemainingCredit=RemainingCredit+'" + courseToTeacher.CourseCredit +
                    "' where id=" + courseToTeacher.TeacherId;


            Command = new SqlCommand(query, Connection);

            Connection.Open();
            int rowEffect = Command.ExecuteNonQuery();

            Connection.Close();



            query   = "INSERT INTO CourseToTeacher VALUES('" + courseToTeacher.TeacherId + "', '" + courseToTeacher.CourseId + "',1)";
            Command = new SqlCommand(query, Connection);
            if (rowEffect > 0)
            {
                Connection.Open();
                rowEffect = Command.ExecuteNonQuery();
                Connection.Close();
            }

            return(rowEffect);
        }
        public string Assign(CourseToTeacherModel courseToTeacher)
        {
            int rowEffect = courseToTeacherGateway.Assign(courseToTeacher);

            if (rowEffect > 0)
            {
                return("Sace Success");
            }
            else
            {
                return("Sace Faild");
            }
        }
Beispiel #3
0
        public ActionResult Save(CourseToTeacherModel courseToTeacher)
        {
            ViewBag.Title       = "Course To Teacher ";
            ViewBag.departments = courseToTeacherManager.DepartmentDropdownlist();

            if (courseToTeacherManager.IsCoursAssigned(courseToTeacher.CourseId) == false)
            {
                ViewBag.message = courseToTeacherManager.Assign(courseToTeacher);
            }
            else
            {
                ViewBag.message = "Course is not available";
            }

            return(View());
        }