public async Task <IActionResult> Create(PageRouteCreateViewModel pageRouteViewModel)
        {
            if (ModelState.IsValid)
            {
                var user = await _userManager.GetUserAsync(HttpContext.User);

                PageRouteVersion pageRouteVersion = new PageRouteVersion();
                pageRouteVersion              = pageRouteViewModel.MapToPageRouteVersion(pageRouteVersion);
                pageRouteVersion.CreatedById  = user.Id;
                pageRouteVersion.CreationDate = DateTime.Now;

                pageRouteVersion.VersionStatusEnum = VersionStatusEnum.Draft;
                pageRouteVersion.ChangeActionEnum  = ChangeActionEnum.New;

                PageRouteVersion newPageRouteVersion = _pageRouteVersionRepository.Add(pageRouteVersion);
                if (newPageRouteVersion != null)
                {
                    _toastNotification.AddSuccessToastMessage(ToasrMessages.AddSuccess);
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Add, "Dynamic Pages ", pageRouteViewModel.EnName);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    _eventLogger.LogInfoEvent(HttpContext.User.Identity.Name, Common.ActivityEnum.Add, "Dynamic Pages ", "Insertion Error");
                    _toastNotification.AddErrorToastMessage(ToasrMessages.warning);
                    return(View());
                }
            }
            List <NavItem>           navItems  = _navItemRepository.Get().ToList();
            PageRouteCreateViewModel viewModel = new PageRouteCreateViewModel(navItems);

            return(View(viewModel));
        }
        public IActionResult Create()
        {
            List <NavItem>           navItems  = _navItemRepository.Get().ToList();
            PageRouteCreateViewModel viewModel = new PageRouteCreateViewModel(navItems);

            return(View(viewModel));
        }
예제 #3
0
        public static PageSeo MapToPageSeo(this PageRouteCreateViewModel pageRouteViewModel)
        {
            PageSeo pageSeo = new PageSeo();

            pageSeo.SeoTitleEN       = pageRouteViewModel.SeoTitleEN;
            pageSeo.SeoTitleAR       = pageRouteViewModel.SeoTitleAR;
            pageSeo.SeoDescriptionEN = pageRouteViewModel.SeoDescriptionEN;
            pageSeo.SeoDescriptionAR = pageRouteViewModel.SeoDescriptionAR;
            pageSeo.SeoOgTitleEN     = pageRouteViewModel.SeoOgTitleEN;
            pageSeo.SeoOgTitleAR     = pageRouteViewModel.SeoOgTitleAR;
            pageSeo.SeoTwitterCardEN = pageRouteViewModel.SeoTwitterCardEN;
            pageSeo.SeoTwitterCardAR = pageRouteViewModel.SeoTwitterCardAR;

            return(pageSeo);
        }
예제 #4
0
        //public static List<PageRouteListViewModel> MapToPageRouteViewModels(this IEnumerable<PageRoute> pageRouteVersions)
        //{
        //    return pageRouteVersions.Select(pageRouteVersion => new PageRouteListViewModel
        //    {
        //        Id = pageRouteVersion.Id,
        //        EnName = pageRouteVersion.EnName,
        //        ArName = pageRouteVersion.ArName,
        //        Order = pageRouteVersion.Order,
        //        IsActive = pageRouteVersion.IsActive,
        //        NavItemArName = (pageRouteVersion.PageRouteVersion != null) ? ((pageRouteVersion.NavItem != null) ? pageRouteVersion.PageRoute.NavItem.ArName : "") : ((pageRouteVersion.NavItem != null) ? pageRouteVersion.NavItem.ArName : ""),
        //        NavItemEnName = (pageRouteVersion.PageRouteVersion != null) ? ((pageRouteVersion.NavItem != null) ? pageRouteVersion.PageRoute.NavItem.EnName : "") : ((pageRouteVersion.NavItem != null) ? pageRouteVersion.NavItem.EnName : ""),
        //        StatusId = pageRouteVersion.StatusId,
        //        StatusName = ((RequestStatus)pageRouteVersion.StatusId).ToString(),
        //        HasSections = pageRouteVersion.PageSectionVersions.Any(),
        //        IsDeleted = pageRouteVersion.IsDeleted
        //    }).ToList();
        //}

        public static PageRouteVersion MapToPageRouteVersion(this PageRouteCreateViewModel pageRouteViewModel, PageRouteVersion pageRouteVersion)
        {
            pageRouteVersion.EnName    = pageRouteViewModel.EnName;
            pageRouteVersion.ArName    = pageRouteViewModel.ArName;
            pageRouteVersion.Order     = pageRouteViewModel.Order;
            pageRouteVersion.IsActive  = pageRouteViewModel.IsActive;
            pageRouteVersion.NavItemId = pageRouteViewModel.NavItemId;

            pageRouteVersion.SeoTitleEN       = pageRouteViewModel.SeoTitleEN;
            pageRouteVersion.SeoTitleAR       = pageRouteViewModel.SeoTitleAR;
            pageRouteVersion.SeoDescriptionEN = pageRouteViewModel.SeoDescriptionEN;
            pageRouteVersion.SeoDescriptionAR = pageRouteViewModel.SeoDescriptionAR;
            pageRouteVersion.SeoOgTitleEN     = pageRouteViewModel.SeoOgTitleEN;
            pageRouteVersion.SeoOgTitleAR     = pageRouteViewModel.SeoOgTitleAR;
            pageRouteVersion.SeoTwitterCardEN = pageRouteViewModel.SeoTwitterCardEN;
            pageRouteVersion.SeoTwitterCardAR = pageRouteViewModel.SeoTwitterCardAR;
            pageRouteVersion.PageType         = pageRouteVersion.PageType;
            return(pageRouteVersion);
        }