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

            //todo: need to check page in this section only
            var checkPage = _pageRepository.FetchPage(page.Name);

            if (checkPage != null)
            {
                MessageBusService.AddIssue(string.Format("A page with the name '{0}' already exists in this section."));
                return false;
            }

            var repPage = Mapper.Map<Page, Rep.Pages.Page>(page);

            if (_pageRepository.Create(repPage, out id))
            {
                var newPage = FetchPage(id);
                AuditService.ObjectAuditLog(ActionType.Create, n => n.ID, newPage);

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

                return true;
            }
            MessageBusService.AddIssue("An error occurred. The section has not been created.");
            return false;
        }
예제 #2
0
        public bool Update(Page page)
        {
            var checkPage = _pageRepository.FetchSection(page.Name);

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

            var repPage = Mapper.Map<Page, Rep.Pages.Page>(page);

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

                return true;
            }

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

            return false;
        }