public ActionResult Update([DataSourceRequest] DataSourceRequest request, CourseInstanceGridViewModel course)
        {
            if (course != null && ModelState.IsValid)
            {
                var target = this.Data.CourseInstances.All(new string[] { "User", "Course" }).FirstOrDefault(c => c.Id == course.Id);
                if (target != null)
                {
                    target.Mark      = course.Mark;
                    target.StartDate = course.StartDate;
                    target.EndDate   = course.EndDate;
                    this.Data.SaveChanges();
                }
            }

            return(Json(new[] { course }.ToDataSourceResult(request, ModelState)));
        }
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, CourseInstanceGridViewModel course)
        {
            if ((course.StartDate != null) && (course.EndDate != null) &&
                (course.StartDate.Value.CompareTo(course.EndDate) > 0))
            {
                ModelState.AddModelError("EndDate", "Start date must preceed end date.");
            }

            if (course != null && ModelState.IsValid)
            {
                var target = this.Data.CourseInstances.All(new string[] { "User", "Course" }).FirstOrDefault(c => c.Id == course.Id);
                if (target != null)
                {
                    target.Mark      = course.Mark;
                    target.StartDate = course.StartDate;
                    target.EndDate   = course.EndDate;
                    this.Data.SaveChanges();
                }
            }

            return(Json(new[] { course }.ToDataSourceResult(request, ModelState)));
        }