Example #1
0
        public ActionResult SaveCourse(Course course)
        {
            try
            {
                // grab course from DB
                using (var context = new SWC_LMSEntities())
                {

                    var dbCourse = context.Courses.FirstOrDefault(x => x.CourseId == course.CourseId);
                    // update course with incoming view model

                    dbCourse.CourseId = course.CourseId;
                    dbCourse.CourseName = course.CourseName;
                    dbCourse.CourseDescription = course.CourseDescription;

                    context.SaveChanges();

                    ViewBag.Message = "Save successful";
                }

            }
            catch (Exception)
            {
                ViewBag.Message = "Error saving user.";
                // throw;
            }
            return View("UserDetails", course);
        }
Example #2
0
 public static List<Course> GetCourseList(Course course)
 {
     List<Course> courses = new List<Course>();
     foreach (var co in courses)
     {
         courses.Add(co);
     }
     return courses.ToList();
 }
Example #3
0
        //      public static void AddCourse(CourseViewModel course)
        //      {
        //          SWC_LMSEntities context = new SWC_LMSEntities();
        //          {
        //          var startDate = DateTime.Parse(course.StartDate);
        //          var endDate = DateTime.Parse(course.EndDate);
        //          context.AddCourse(course.CourseId, course.SubjectId, course.CourseName, course.CourseDescription, course.IsArchived, startDate, endDate);
        //context.SaveChanges();
        //          }
        //      }
        public static void EditCourse(CourseViewModel course)
        {
            SWC_LMSEntities context = new SWC_LMSEntities();
            {

                Course newCourse = new Course();
                newCourse.CourseName = "Test Info";
                newCourse.CourseDescription = "Test Info Desc";
                newCourse.StartDate = DateTime.Now;
                newCourse.EndDate = DateTime.Now;
                context.Courses.Add(newCourse);
                context.SaveChanges();

            }
        }