Exemple #1
0
 private void SubmitMethod(ApplicationUser user, ChangeActionEnum changeActionEnum, int relatedId)
 {
     ApprovalNotification approval = new ApprovalNotification()
     {
         ChangeAction      = changeActionEnum,
         VersionStatusEnum = VersionStatusEnum.Submitted,
         ChangesDateTime   = DateTime.Now,
         ChangeType        = ChangeType.PageContent,
         PageLink          = $"/{nameof(FormerMinistriesController)[0..^10]}",
Exemple #2
0
        /// <summary>
        /// save and submit changes for the approval user
        /// </summary>
        /// <param name="changeActionEnum"></param>
        /// <param name="relatedId">related object id in notification</param>
        /// <returns></returns>
        private async Task SaveAndSubmitMethod(ChangeActionEnum changeActionEnum, int relatedId)
        {
            var pageRouteVer = _pageRouteVersionRepository.Get(relatedId);
            var frv          = _formerMinistriesPageInfoVersionRepository.Get();
            var user         = await _userManager.GetUserAsync(HttpContext.User);

            if (frv.VersionStatusEnum != VersionStatusEnum.Submitted)
            {
                frv.VersionStatusEnum = VersionStatusEnum.Submitted;
                pageRouteVer.ContentVersionStatusEnum = VersionStatusEnum.Submitted;
                _pageRouteVersionRepository.Update(pageRouteVer);
                _formerMinistriesPageInfoVersionRepository.Update(frv);
                var ministries = _ministryTimeLineVersionsRepository.GetAllByPageInfo(frv);
                SubmitMethod(user, changeActionEnum, relatedId);
            }
            _toastNotification.AddSuccessToastMessage(ToasrMessages.SubmitSuccess);
            _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Submitted, "Static Page > Former Ministries", "Submitted ");
            if (!frv.MinistryTimeLineVersions.Any())
            {
                CopyMinistries(frv);
            }
        }
        /// <summary>
        /// save and submit static page route
        /// </summary>
        /// <param name="pageRouteViewModel"></param>
        /// <param name="changeActionEnum"></param>
        /// <returns></returns>
        private async Task SaveAndSubmitMethod(PageRouteEditViewModel pageRouteViewModel, ChangeActionEnum changeActionEnum)
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var pageRoutVersionId    = 0;
            var oldVersionStatusEnum = pageRouteViewModel.VersionStatusEnum ?? VersionStatusEnum.Submitted;

            pageRouteViewModel.VersionStatusEnum = VersionStatusEnum.Submitted;
            EditMethod(pageRouteViewModel, VersionStatusEnum.Submitted, oldVersionStatusEnum, changeActionEnum, user.Id, out pageRoutVersionId, true);
            var pageRouteVersion = _pageRouteVersionRepository.Get(pageRoutVersionId);

            if (pageRoutVersionId != pageRouteViewModel.Id || oldVersionStatusEnum != VersionStatusEnum.Submitted)
            {
                SubmitMethod(user, pageRouteVersion);
            }
        }
        /// <summary>
        /// edit static page route
        /// </summary>
        /// <param name="pageRouteViewModel"></param>
        /// <param name="newVersionStatusEnum"></param>
        /// <param name="oldVersionStatusEnum"></param>
        /// <param name="changeActionEnum"></param>
        /// <param name="userId"></param>
        /// <param name="pageRoutVersionId"></param>
        /// <returns></returns>
        private IActionResult EditMethod(PageRouteEditViewModel pageRouteViewModel, VersionStatusEnum newVersionStatusEnum, VersionStatusEnum oldVersionStatusEnum, ChangeActionEnum changeActionEnum, string userId, out int pageRoutVersionId, bool fromSaveAndSubmit = false)
        {
            List <NavItem> navItems;

            if (!pageRouteViewModel.HasNavItem)
            {
                ModelState.Remove("NavItemId");
            }


            PageRouteVersion pageRouteVersion = pageRouteViewModel.MapToPageRouteVersion();

            if (ModelState.IsValid)
            {
                if (oldVersionStatusEnum == VersionStatusEnum.Approved || oldVersionStatusEnum == VersionStatusEnum.Ignored)
                {
                    pageRouteVersion.CreatedById       = userId;
                    pageRouteVersion.CreationDate      = DateTime.Now;
                    pageRouteVersion.VersionStatusEnum = newVersionStatusEnum;
                    pageRouteVersion.ChangeActionEnum  = changeActionEnum;
                    pageRouteVersion.Id = 0;
                    _pageRouteVersionRepository.AddStaticPage(pageRouteVersion);
                    pageRoutVersionId = pageRouteVersion.Id;
                    if (!fromSaveAndSubmit)
                    {
                        _toastNotification.AddSuccessToastMessage(ToasrMessages.EditSuccess);
                    }
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Add, "Definitions > Static Pages > Add", pageRouteViewModel.EnName);
                    return(RedirectToAction(nameof(Index)));
                }
                PageRouteVersion newPageRouteVersion = _pageRouteVersionRepository.Update(pageRouteVersion);
                if (newPageRouteVersion != null)
                {
                    if (!fromSaveAndSubmit)
                    {
                        _toastNotification.AddSuccessToastMessage(ToasrMessages.EditSuccess);
                    }
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Update, "Definitions > Static Pages > Edit", pageRouteViewModel.EnName);
                    pageRoutVersionId = pageRouteVersion.Id;
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    _toastNotification.AddErrorToastMessage(ToasrMessages.warning);
                    navItems = _navItemRepository.Get().ToList();
                    pageRouteViewModel.NavItems = navItems;
                    pageRoutVersionId           = pageRouteVersion.Id;
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Warning, "Definitions > Static Pages > Edit", pageRouteViewModel.EnName);
                    return(View(pageRouteViewModel));
                }
            }
            navItems = _navItemRepository.Get().ToList();
            pageRouteViewModel.NavItems = navItems;
            pageRoutVersionId           = pageRouteVersion.Id;
            return(View(pageRouteViewModel));
        }
Exemple #5
0
 /// <summary>
 /// Adds new item (i.e. role or user) into the cumulated collections.
 /// </summary>
 /// <param name="guid">ID that is common for both CMS and AD</param>
 /// <param name="displayName">Text that should be displayed in CMS event log (i.e. user name or role display name)</param>
 /// <param name="action">Action that was performed over the item.</param>
 public void Add(Guid guid, string displayName, ChangeActionEnum action)
 {
     mSets[action][guid] = displayName;
 }
Exemple #6
0
 /// <summary>
 /// Gets stored item display names for given <see cref="ChangeActionEnum"/> type.
 /// </summary>
 /// <param name="changeType">Type of change to get display names for</param>
 private ICollection <string> GetDisplayNames(ChangeActionEnum changeType)
 {
     return(mSets[changeType].Select(x => x.Value).ToArray());
 }