当前位置: 首页>>代码示例>>C#>>正文


C# Course.Save方法代码示例

本文整理汇总了C#中Course.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Course.Save方法的具体用法?C# Course.Save怎么用?C# Course.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Course的用法示例。


在下文中一共展示了Course.Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HomeModule

        public HomeModule()
        {
            Get["/"]=_=>View["index.cshtml"];

              Get["/courses"]=_=>
              {
            List<Course> allCourses = Course.GetAll();
            return View["courses.cshtml", allCourses];
              };

              Get["/courses/new"]=_=>{
            List<Department> departments = Department.GetAll();
            return View["course_new.cshtml" , departments];
            };

              Post["/courses/new"]=_=>
              {
            Course newCourse = new Course(Request.Form["course-name"], Request.Form["department"]);
            newCourse.Save();
            List<Course> allCourses = Course.GetAll();
            return View["courses.cshtml", allCourses];
              };

              // Get["courses/{id}"] = parameters =>
              // {
              //   Course course = Course.Find(parameters.id);
              //   return View["course.cshtml", course];
              // };

              Get["students/{id}"] = parameters =>
              {
            Student student = Student.Find(parameters.id);
            return View["student.cshtml", student];
              };

              Get["/students"]=_=>
              {
            List<Student> allStudents = Student.GetAll();
            return View["students.cshtml", allStudents];
              };

              Get["/students/new"]=_=>View["student_new.cshtml"];

              Post["/students/new"]=_=>
              {
            Student newStudent = new Student(Request.Form["student-name"], Request.Form["enrollment-date"]);
            newStudent.Save();
            List<Student> allStudents = Student.GetAll();
            return View["students.cshtml", allStudents];
              };
              Post["/students/{id}/addCourse"] = parameters =>
              {
            Student student = Student.Find(parameters.id);
            student.AddCourse(Request.Form["course"]);
            return View["student.cshtml", student];
              };
              Post["/students/{id}/deleteCourse"] = parameters =>
              {
            Student student = Student.Find(parameters.id);
            student.DropCourse(Request.Form["course"]);
            return View["student.cshtml", student];
              };

              Post["/students/{id}/updatemajors"]=parameters=>
              {
            Student student = Student.Find(parameters.id);
            int majorCount = student.GetMajors().Count;
            if(majorCount == 0 && Request.Form["new-major"] !=0)
            {
              student.AddMajor(Request.Form["new-major"]);
            }
            else if(majorCount == 1)
            {
              if(Request.Form["current-major"]==0)
              {
            student.DropMajor(Request.Form["current-major"]);
              }
              else if(Request.Form["current-major"]!=student.GetMajors()[0].GetId())
              {
            student.DropMajor(student.GetMajors()[0].GetId());
            student.AddMajor(Request.Form["current-major"]);
              }
              if(Request.Form["additional-major"] !=0)
              {
            student.AddMajor(Request.Form["additonal-major"]);
              }
            }
            else
            {
              if(Request.Form["first-major"]==0)
              {
            student.DropMajor(Request.Form["first-major"]);
              }
              else if(Request.Form["first-major"]!=student.GetMajors()[0].GetId())
              {
            student.DropMajor(student.GetMajors()[0].GetId());
            student.AddMajor(Request.Form["first-major"]);
              }
              if(Request.Form["second-major"]==0)
              {
//.........这里部分代码省略.........
开发者ID:CharlesEwel,项目名称:registrar,代码行数:101,代码来源:HomeModule.cs


注:本文中的Course.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。