Exemplo n.º 1
0
        public ActionResult CreateCourseSetEntry([DataSourceRequest] DataSourceRequest dsRequest, CourseSetEntry courseSet)
        {
            if (courseSet != null && ModelState.IsValid)
              {
            var setId = Convert.ToInt32(courseSet.CourseSetId);
            var set = this.context.CourseSets.FirstOrDefault(t => t.Id == setId);
            var template = this.context.CourseTemplates.FirstOrDefault(t => t.Id == courseSet.CourseTemplate.Id);
            courseSet.CourseSet = set;
            courseSet.CourseTemplate = template;
            if (set.Entries == null)
            {
              set.Entries = new List<CourseSetEntry>();
            }
            set.Entries.Add(courseSet);
            this.context.SaveChanges();
              }

              return this.Json(ModelState.ToDataSourceResult());
        }
Exemplo n.º 2
0
        public ActionResult DeleteCourseSetEntry([DataSourceRequest] DataSourceRequest dsRequest, CourseSetEntry courseSetEntry)
        {
            this.context.CourseSetEntries.Remove(this.context.CourseSetEntries.SingleOrDefault(c => c.Id == courseSetEntry.Id));
              this.context.SaveChanges();

              return this.Json(ModelState.ToDataSourceResult());
        }