Пример #1
0
        public bool Update(Section section)
        {
            var checkSection = _pageRepository.FetchSection(section.Name);

            if (checkSection != null)
            {
                if (String.Equals(section.Name, checkSection.Name, StringComparison.InvariantCultureIgnoreCase) && section.ID != checkSection.ID)
                {
                    MessageBusService.AddIssue(string.Format("A section with the name '{0}' already exists.", section.Name));
                    return false;
                }
            }

            var repSection = Mapper.Map<Section, Rep.Pages.Section>(section);

            if (_pageRepository.Update(repSection))
            {
                //   var updated = Fetch(course.ID);
                //AuditService.ObjectAuditLog(ActionType.Update, n => n.ID, updated);
                //   EventManagerService.QueueEvent(new SectionUpdatedEvent(updated));

                return true;
            }

            MessageBusService.AddIssue("An error occurred. The section was not updated.");

            return false;
        }
Пример #2
0
        public bool Create(Section section, out int id)
        {
            id = -1;

            var checkSection = _pageRepository.FetchSection(section.Name);

            if (checkSection != null)
            {
                MessageBusService.AddIssue(string.Format("A section with the name '{0}' already exists.", section.Name));
                return false;
            }

            var repSection = Mapper.Map<Section, Rep.Pages.Section>(section);

            if (_pageRepository.Create(repSection, out id))
            {
                //var newSection = FetchSection(id);
             //   AuditService.ObjectAuditLog(ActionType.Create, n => n.ID, newSection);

               // EventManagerService.QueueEvent(new SectionCreatedEvent(section));

                return true;
            }
            MessageBusService.AddIssue("An error occurred. The section has not been created.");
            return false;
        }