Example #1
0
 /// <summary>
 /// MapContentPageQueueToContentPage
 /// </summary>
 /// <param name="contentPage"></param>
 /// <param name="contentPageinQueue"></param>
 private void MapContentPageQueueToContentPage(ContentPage contentPage, TempContentPage contentPageInQueue)
 {
     Mapper.Map<TempContentPage, ContentPage>(contentPageInQueue, contentPage);
 }
Example #2
0
        /// <summary>
        /// SaveContentPage
        /// </summary>
        /// <param name="contentPage"></param>
        /// <returns></returns>
        public void SaveContentPage(ContentPage contentPage)
        {
            #region Check Permission

            List<PermissionEnum> userPermissions = _securityManager.GetUserFeaturePermissions(UserContextDetails.UserId, FeatureEnum.ContentPage);
            if ((contentPage.ContentPageId.Equals(0) && !userPermissions.Contains(PermissionEnum.AddContent)) || (!contentPage.ContentPageId.Equals(0) && !userPermissions.Contains(PermissionEnum.EditContent)))
                throw new BusinessException(_coreValidationResourceManager.GetString(CoreValidationMessagesConstants.UnAuthorized), CoreValidationMessagesConstants.UnAuthorized);

            #endregion

            //check contentSetting
            SecurityManager securityManager = new SecurityManager();
            List<SiteContentSettingResult> siteContentSettingResults = securityManager.GetSiteFeatureSettings(FeatureEnum.ContentPage);

            bool approvalRequired = siteContentSettingResults.Where(qry => qry.ContentSettingId.Equals((int)FeatureSettingEnum.ApprovalRequired)).FirstOrDefault().IsAssigned;
            //self approved in case approval not required
            if (!approvalRequired)
            {
                contentPage.ApprovalStatus = WorkflowConstants.ApprovedStatus;
                contentPage.ApproveRejectDate = DateTime.UtcNow;
                contentPage.ApproveRejectById = UserContextDetails.UserId;
            }
            else
            {
                contentPage.ApprovalStatus = WorkflowConstants.ApprovalWaitingStatus;
                contentPage.ApproveRejectById = null;
                contentPage.ApproveRejectDate = null;
            }

            if (contentPage.ContentPageId.Equals(0)) // New ContentPage
            {
                contentPage.CreatedById = UserContextDetails.UserId;
                contentPage.CreatedOn = DateTime.UtcNow;
                if (approvalRequired)
                    contentPage.ApprovalStatus = WorkflowConstants.ApprovalWaitingStatus;

                eCollabroDbContext.Repository<ContentPage>().Insert(contentPage);
                eCollabroDbContext.Save();

                if (approvalRequired)
                {
                    _workflowManager.CreateWorkflowTask(ContextEnum.ContentPage, contentPage.ContentPageId, "New Content Page [" + contentPage.ContentPageTitle + "] ", "Content Page Description : " + contentPage.ContentPageDescription);
                }

            }
            else  // Update ContentPage
            {
                ContentPage oldContentPage = eCollabroDbContext.Repository<ContentPage>().Query().Filter(qry => qry.ContentPageId.Equals(contentPage.ContentPageId)).Get().FirstOrDefault();
                if (oldContentPage != null)
                {
                    if (approvalRequired && oldContentPage.ApprovalStatus.Equals(WorkflowConstants.ApprovedStatus)) // Save to Queue
                    {
                        contentPage.ModifiedById = UserContextDetails.UserId;
                        contentPage.ModifiedOn = DateTime.UtcNow;
                        contentPage.ApprovalStatus = WorkflowConstants.ApprovalWaitingStatus;
                        TempContentPage tempContentPage = Mapper.Map<ContentPage, TempContentPage>(contentPage);
                        _workflowManager.SaveToQueue<TempContentPage>(tempContentPage, ContextEnum.ContentPage, tempContentPage.ContentPageId);
                        _workflowManager.CreateWorkflowTask(ContextEnum.ContentPage, contentPage.ContentPageId, "New Content Page [" + contentPage.ContentPageTitle + "] ", "Content Page Description : " + contentPage.ContentPageDescription);

                    }
                    else // Record is new and not in Queue
                    {
                        oldContentPage.ContentPageTitle = contentPage.ContentPageTitle;
                        oldContentPage.ContentPageDescription = contentPage.ContentPageDescription;
                        oldContentPage.ContentPageContent = contentPage.ContentPageContent;
                        oldContentPage.ContentPageCategoryId = contentPage.ContentPageCategoryId;
                        oldContentPage.IsActive = contentPage.IsActive;
                        oldContentPage.IsAnomynousAccess = contentPage.IsAnomynousAccess;
                        oldContentPage.IsCommentsAllowed = contentPage.IsCommentsAllowed;
                        oldContentPage.IsLikeAllowed = contentPage.IsLikeAllowed;
                        oldContentPage.IsRatingAllowed = contentPage.IsRatingAllowed;
                        oldContentPage.IsVotingAllowed = contentPage.IsVotingAllowed;
                        oldContentPage.ModifiedById = UserContextDetails.UserId;
                        oldContentPage.ModifiedOn = DateTime.UtcNow;

                        oldContentPage.ApprovalStatus = contentPage.ApprovalStatus;
                        oldContentPage.ApproveRejectDate = contentPage.ApproveRejectDate;
                        oldContentPage.ApproveRejectById = contentPage.ApproveRejectById;
                        eCollabroDbContext.Save();
                        if (approvalRequired) // approval required // create or update task
                        {
                            _workflowManager.CreateWorkflowTask(ContextEnum.ContentPage, contentPage.ContentPageId, "New Content Page [" + contentPage.ContentPageTitle + "] ", "Content Page Description : " + contentPage.ContentPageDescription);
                        }
                    }
                }
                else
                {
                    throw new DBConcurrencyException();
                }
            }
        }