Example #1
0
        public ActionResult DeleteCourse(string courseId)
        {
            try
            {
                Course c = service.GetObject(Int64.Parse(courseId));

                ICourseChangeRepository            courseChangeRepository            = ObjectFactory.GetInstance <ICourseChangeRepository>();
                ICourseClassRepository             courseClassRepository             = ObjectFactory.GetInstance <ICourseClassRepository>();
                ICourseTimeRepository              courseTimeRepository              = ObjectFactory.GetInstance <ICourseTimeRepository>();
                IAttachmentCourseRepository        attachmentCourseRepository        = ObjectFactory.GetInstance <IAttachmentCourseRepository>();
                ISelectableCourseStudentRepository selectableCourseStudentRepository = ObjectFactory.GetInstance <ISelectableCourseStudentRepository>();

                foreach (var x in attachmentCourseRepository.GetObjectList(x => x.CourseId == c.Id, x => x.CourseId, Core.Enums.OrderingType.Ascending, 0, 0))
                {
                    attachmentCourseRepository.Delete(x);
                }

                foreach (var x in courseClassRepository.GetObjectList(x => x.Courses_Id == c.Id, x => x.Courses_Id, Core.Enums.OrderingType.Ascending, 0, 0))
                {
                    courseClassRepository.Delete(x);
                }

                foreach (var x in courseChangeRepository.GetObjectList(x => x.CourseId == c.Id, x => x.CourseId, Core.Enums.OrderingType.Ascending, 0, 0))
                {
                    courseChangeRepository.Delete(x);
                }

                foreach (var x in courseTimeRepository.GetObjectList(x => x.CourseId == c.Id, x => x.CourseId, Core.Enums.OrderingType.Ascending, 0, 0))
                {
                    courseTimeRepository.Delete(x);
                }

                foreach (var x in selectableCourseStudentRepository.GetObjectList(x => x.SelectedCourses_Id == c.Id, x => x.SelectedCourses_Id, Core.Enums.OrderingType.Ascending, 0, 0))
                {
                    selectableCourseStudentRepository.Delete(x);
                }

                service.DeleteObject(c);
                return(Content("success"));
            }
            catch (Exception e)
            {
                return(Content(e.Message));
            }
        }
Example #2
0
        public ActionResult DeleteCourseChange()
        {
            try
            {
                var cid  = Int64.Parse(Request.QueryString["cid"]);
                var time = DateTime.Parse(Request.QueryString["time"]);

                ICourseChangeRepository courseChangeRepository = StructureMap.ObjectFactory.GetInstance <ICourseChangeRepository>();

                courseChangeRepository.Delete(courseChangeRepository.GetFirstOrDefaultObject(x => x.CourseTime == time && x.CourseId == cid));

                return(Content("success"));
            }
            catch (Exception e)
            {
                return(Content(e.Message));
            }
        }