예제 #1
0
        public bool Create(Course course, out int id)
        {
            id = -1;

            var checkCourse = _courseRepository.Fetch(course.Name);

            if (checkCourse != null)
            {

                /* if (checkApp.Archived)
                 {
                     NotificationService.AddIssue(ResourceManager.ApplicationManager_Create_ApplicationArchived());
                     return false;
                 }*/

                if (String.Equals(course.Name, checkCourse.Name, StringComparison.InvariantCultureIgnoreCase))
                {
                    //   MessageBusService.AddIssue(ResourceManager.CourseManager_Create_CourseNameExists());
                    return false;
                }

                if (String.Equals(course.Abbreviation, checkCourse.Abbreviation, StringComparison.InvariantCultureIgnoreCase))
                {
                    //   MessageBusService.AddIssue(ResourceManager.CourseManager_Create_CourseAbbreviationExists());
                    return false;
                }
                /*
                if (course.CourseYears.HasContent())
                {
                    if (course.CourseYears.GroupBy(n => n).Any(m => m.Key.Name.Count() > 1))
                    {
                        //TODO: a duplicate error stating a course year already exists with same name?
                    }
                }*/
            }

            var repCourse = Mapper.Map<Course, Rep.Courses.Course>(course);
            if (_courseRepository.Create(repCourse, out id))
            {
                var newCourse = Fetch(id);
                AuditService.ObjectAuditLog(ActionType.Create, n => n.ID, newCourse);

                EventManagerService.QueueEvent(new CourseCreatedEvent(course));

                return true;
            }

            //   MessageBusService.AddError(ResourceManager.CourseManager_Create_Error());
            return false;
        }
예제 #2
0
 public CourseCreatedEvent(Course course)
 {
     _course = course;
 }
예제 #3
0
 public CourseRolledBackEvent(Course course)
 {
     _course = course;
 }
예제 #4
0
 public CourseUpdatedEvent(Course course)
 {
     _course = course;
 }
예제 #5
0
        public bool Update(Course course)
        {
            var checkCourse = _courseRepository.Fetch(course.Name);

            if (checkCourse != null)
            {
                if (String.Equals(course.Name, checkCourse.Name, StringComparison.InvariantCultureIgnoreCase) && course.ID != checkCourse.ID)
                {
                    //  MessageBusService.AddIssue(ResourceManager.CourseManager_Update_CourseNameExists());
                    return false;
                }

                if (String.Equals(course.Abbreviation, checkCourse.Abbreviation, StringComparison.InvariantCultureIgnoreCase) && course.ID != checkCourse.ID)
                {
                    //  MessageBusService.AddIssue(ResourceManager.CourseManager_Update_CourseAbbreviationExists());
                    return false;
                }
            }

            var repApp = Mapper.Map<Course, Rep.Courses.Course>(course);
            if (_courseRepository.Update(repApp))
            {
                var updated = Fetch(course.ID);
                AuditService.ObjectAuditLog(ActionType.Update, n => n.ID, updated);
                EventManagerService.QueueEvent(new CourseUpdatedEvent(updated));

                return true;
            }

            // MessageBusService.AddError(ResourceManager.CourseManager_Update_Error());
            return false;
        }
예제 #6
0
 public CourseDeletedEvent(Course course)
 {
     _course = course;
 }