//
        // GET: /Assignment/Create
        public ActionResult Create(int courseId)
        {
            var model = new CreateEditAssignmentModel
            {
                CourseId = courseId
            };

            return View(model);
        }
        public ActionResult Create(CreateEditAssignmentModel model)
        {
            if (ModelState.IsValid)
            {
                var course = ConsumerContext.Courses.Find(model.CourseId);
                var assignment = new Assignment
                {
                    ConsumerKey = model.ConsumerKey,
                    ConsumerSecret = model.ConsumerSecret,
                    Course = course,
                    CustomParameters = model.CustomParameters,
                    Description = model.Description,
                    Name = model.Name,
                    Url = model.Url
                };

                ConsumerContext.Assignments.Add(assignment);
                ConsumerContext.SaveChanges();

                return RedirectToAction("Details", "Course", new { id = model.CourseId });
            }
            return View(model);
        }
 public ActionResult Edit(CreateEditAssignmentModel model)
 {
     if (ModelState.IsValid)
     {
         var assignment = ConsumerContext.Assignments.Find(model.AssignmentId);
         assignment.ConsumerKey = model.ConsumerKey;
         assignment.ConsumerSecret = model.ConsumerSecret;
         assignment.Course = ConsumerContext.Courses.Find(model.CourseId);
         assignment.CustomParameters = model.CustomParameters;
         assignment.Description = model.Description;
         assignment.Name = model.Name;
         assignment.Url = model.Url;
         ConsumerContext.Entry(assignment).State = EntityState.Modified;
         ConsumerContext.SaveChanges();
         return RedirectToAction("Details", "Course", new { id = model.CourseId });
     }
     return View(model);
 }
 //
 // GET: /Assignment/Edit/5
 public ActionResult Edit(int id = 0)
 {
     var assignment = ConsumerContext.Assignments.Find(id);
     if (assignment == null)
     {
         return HttpNotFound();
     }
     var model = new CreateEditAssignmentModel(assignment);
     return View(model);
 }